data structures using until the tree has only one node such tree with only one node is known as the huffman tree the huffman algorithm can be implemented using priority queue in which all the nodes are placed in such way that the node with the lowest weight is given the highest priority the algorithm is shown in fig step create leaf node for each character add the character and its weight or frequency of occurrence to the priority queue step repeat steps to while the total number of nodes in the queue is greater than step remove two nodes that have the lowest weight (or highest prioritystep create new internal node by merging these two nodes as children and with weight equal to the sum of the two nodesweights step add the newly created node to the queue figure huffman algorithm example create huffman tree with the following nodes arranged in priority queue