Essays.club - Получите бесплатные рефераты, курсовые работы и научные статьи
Поиск

Кодирование информации методом Хаффмана

Автор:   •  Июнь 12, 2019  •  Лабораторная работа  •  490 Слов (2 Страниц)  •  357 Просмотры

Страница 1 из 2

Листинг:

MainForm:

using System;

using System.Collections;

using System.Windows.Forms;

namespace Coding

{

public partial class MainForm : Form

{

public MainForm()

{

InitializeComponent();

}

HuffmanTree huffmanTree = new HuffmanTree();

BitArray encoded;

private void btnEncode_Click(object sender, EventArgs e)

{

string input = txtBoxSource.Text;

huffmanTree.Build(input);

encoded = huffmanTree.Encode(input);

foreach (bool bit in encoded)

{

txtBoxResult.Text = txtBoxResult.Text + (bit ? 1 : 0);

}

}

private void btnDecode_Click(object sender, EventArgs e)

{

string decoded = huffmanTree.Decode(encoded);

txtBoxResult.Text = "Decoded: " + decoded;

}

}

}

using System.Linq;

using System.Collections;

using System.Collections.Generic;

namespace Coding

{

public class Tree

{

private List<Node> nodes = new List<Node>();

public Node Root { get; set; }

public Dictionary<char, int> Frequencies = new Dictionary<char, int>();

List<bool> encodedSource;

public void Build(string source)

...

Скачать:   txt (1.6 Kb)   pdf (33.7 Kb)   docx (7.9 Kb)  
Продолжить читать еще 1 страницу »
Доступно только на Essays.club