why we use only min heap in huffman encoding.
What if we use max heap for the same purpose
Huffman Encoding Heap
Min Heap is used as a priority queue.
The value of frequency field is used to compare two nodes in min heap.
Initially, the least frequent character is at root
A min heap to construct the Huffman tree. At each step, we choose the two items with minimal probability, and merge them.
If we use a max heap if would be otherwise and will give Wrong Answer.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.