简体   繁体   中英

Huffman Coding Algorithm(Priority queue vs Sorted queue)

I am little confuse whether huffman algorithm uses priority queue or sorted queue to build huffman tree? For example: https://www.geeksforgeeks.org/greedy-algorithms-set-3-huffman-coding/ .

In the above link they are saying that use minimum heap but as i can see they have just used sorted list to make huffman tree.Please correct me if I am wrong.

A minheap is used to create a priority queue which is a form of a sorted queue. And yes, any sorted data structure can be used to help create a huffman code; however, a heap is traditionally used because the huffman tree is basically a specialized construction of a max heap.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM