is the huffman coding algorithm the huffman coding algorithm begins with each of the distinct characters of the string to encode being the root node of single-node binary tree the algorithm proceeds in series of rounds in each roundthe algorithm takes the two binary trees with the smallest frequencies and merges them into single binary tree it repeats this process until only one tree is left (see code fragment each iteration of the while loop in huffman' algorithm can be implemented in (logdtime using priority queue represented with heap in additioneach iteration takes two nodes out of and adds one ina process that will be repeated times before exactly one node is left in thusthis algorithm runs in ( dlogdtime although full justification of this algorithm' correctness is beyond our scope herewe note that its intuition comes from simple idea--any optimal code can be converted into an optimal code in which the code words for the two lowest-frequency charactersa and bdiffer only in their last bit repeating the argument for string with and replaced by character cgives the followingproposition huffman' algorithm constructs an optimal prefix code for string of length with distinct characters in ( dlogdtime code fragment huffman coding algorithm