Constructing Huffman Codes (A FOREST is a collection of TREES; each TREE has a root and a weight)
While there is more than one TREE in the FOREST {
i= index of the TREE in FOREST with smallest weight;
j= index of the TREE in FOREST with 2nd smallest weight;
Create a new node with left child FOREST(i)--> root and right child FOREST(j)--> root
Replace TREE i in FOREST by a tree whose root is the new node and whose weight is FOREST(i)--> weight + FOREST(j)--> weight
Delete TREE j from FOREST }