It is not Huffman Coding. It is Optimal merge pattern problem. The below image might help you
I guess you are talking about complexity of huffman coding.
1.We have n keys,and we need to merge tree n-1 time to generate final tree.
2.we use min heap to store frequency of every node.
3.In ever iteration we find out top two min frequencies ------->logn time
4.Then we merge those two frequencies and insert in the tree again---->logn
we repeat this process n- 1 time,then total complexity of huffman coding is =(n-1)*(3logn)=O(nlogn)
https://gateoverflow.in/466/gate1999-2-20
64.3k questions
77.9k answers
243k comments
79.6k users