Example #1
0
 public HuffmanNode(HuffmanNode a, HuffmanNode b)
 {
     this.Value = a.Value + b.Value;
     this.Weight = a.Weight + b.Weight;
     this.Left = a;
     this.Right = b;
     this.IsLeaf = false;
 }
        private HuffmanNode BuildTree()
        {
            while (this.Symbols.Count > 1)
            {
                var a = this.Symbols.Poll();
                var b = this.Symbols.Poll();
                var c = new HuffmanNode(a, b);
                this.Symbols.Add(c);
            }

            return this.Symbols.Poll();
        }