figure child and ' represents following the right child finished tree that has leaf nodes will have internal nodes the running time of the algorithm depends on the length of the paths in the tree sobefore going into further details of huffman codinglet us first learn how to calculate the length of the paths in the tree the external path length of binary tree is defined as the sum of all path lengths summed over each path from the root to an external node the internal path length is also defined in the same manner the internal path length of binary tree is defined as the sum of all path lengths summed over each path from the root to an internal node look at the binary tree given in fig binary tree the internal path lengthli the external path lengthle note thatli le thusli lewhere is the number of internal nodes now if the tree has external nodes and each external node is assigned weightthen the weighted path length is defined as the sum of the weighted path lengths thereforep wnln where wi and li are the weight and path length of an external node ni example consider the trees and given belowcalculate their weighted external path lengths binary tree solution weighted external path length of can be given asp * * * * * * weighted external path length of can be given asp * * * * * weighted external path length of can be given asp * * * * technique given nodes and their weightsthe huffman algorithm is used to find tree with minimumweighted path length the process essentially begins by creating new node whose children are the two nodes with the smallest weightsuch that the new node' weight is equal to the sum of the children' weight that isthe two nodes are merged into one node this process is repeated