Question: In Java implement the Huffman coding algorithm in Code Fragment 13.5 and run your code on Example in Figure 13.12. Your program should print out

In Java implement the Huffman coding algorithm in Code Fragment 13.5 and run your code on Example in Figure 13.12. Your program should print out the table in Figure 13.12 (a) and the tree in Figure 13.12 (b) and the binary code of each character.

In Java implement the Huffman coding algorithm in Code Fragment 13.5 andrun your code on Example in Figure 13.12. Your program should print

gorithm Huffman (X) : Input: String X of length n with d distinct characters Output: Coding tree for X Compute the frequency f(c) of each character c of X. Initialize a priority queue Q. for each character c in X do Create a single-node binary tree T storing c. Insert T into Q with key f(c). while Qsize()>1 do Entry e1=Q.removeMin( ) with e1 having key f1 and value T1. Entry e2=Q.removeMin() with e2 having key f2 and value T2. Create a new binary tree T with left subtree T1 and right subtree T2. Insert T into Q with key f1+f2. Entry e=Q.removeMin( ) with e having tree T as its value. return tree T Code Fragment 13.5: Huffman coding algorithm. (b)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!