简体   繁体   English

霍夫曼编码算法(优先级队列与已排序队列)

[英]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/ . 例如: 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. Minheap用于创建优先级队列,它是排序队列的一种形式。 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. 但是,传统上使用堆是因为霍夫曼树基本上是最大堆的专门构造。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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