static void HuffmanTest() { Console.WriteLine("Huffman encoding test"); HuffmanCode hc = new HuffmanCode(); hc.Frequencies["omri"] = 35; hc.Frequencies["had"] = 3; hc.Frequencies["a"] = 107; hc.Frequencies["little"] = 53; hc.Frequencies["lamb"] = 27; hc.ComputeCodes(); foreach (var key in hc.Codes.Keys) { Console.WriteLine(String.Format("{0}: {1}", key, hc.Codes[key])); } }
static void HuffmanTestCLR() { Console.WriteLine("Huffman encoding test with CLR input"); HuffmanCode hc = new HuffmanCode(); hc.Frequencies["f"] = 5; hc.Frequencies["e"] = 9; hc.Frequencies["c"] = 12; hc.Frequencies["b"] = 13; hc.Frequencies["d"] = 16; hc.Frequencies["a"] = 45; hc.ComputeCodes(); foreach (var key in hc.Codes.Keys) { Console.WriteLine(String.Format("{0}: {1}", key, hc.Codes[key])); } }