Skip to content
Related Articles

Related Articles

Save Article
Improve Article
Save Article
Like Article

Algorithms | Greedy Algorithms | Question 3

  • Last Updated : 28 Jun, 2021

What is the time complexity of Huffman Coding?
(A) O(N)
(B) O(NlogN)
(C) O(N(logN)^2)
(D) O(N^2)

Answer: (B)

Explanation: O(nlogn) where n is the number of unique characters. If there are n nodes, extractMin() is called 2*(n – 1) times. extractMin() takes O(logn) time as it calles minHeapify(). So, overall complexity is O(nlogn).
See here for more details of the algorithm.

Quiz of this Question

My Personal Notes arrow_drop_up
Recommended Articles
Page :