(Java) Huffman Coding: Start from Weiss, pg. 500, problem 12.1: Problem 12.1: Sh
ID: 3774241 • Letter: #
Question
(Java)
Huffman Coding: Start from Weiss, pg. 500, problem 12.1:
Problem 12.1: Show the Huffman tree that results from the following distribution of punctuation characters and digits: colon (100), space (605), newline (100), comma (705), 0 (431), 1 (242), 2 (176), 3 (59), 4 (185), 5 (250), 6 (174), 7 (199), 8 (205), and 9 (217).
(a) To make the tree fully-specified, put the lower-weight subtree on the right on each merge operation, and adjust newline’s frequency to 101. Start by listing the weights in increasing order from left to right, with their symbols below them on the next line, leaving space above to build trees. You will find that you need to move the space symbol down to the other end, when it gets chosen.
(b) What is the resulting binary code for the most frequent symbol? The least frequent?
(c) With the coding scheme above, code the 7-symbol text “04: 19,” . Show the binary string and the bytes in hex. (d) With the coding scheme of problem 1, decode 11001110111100000.
(e) Suppose we want to do fast decoding for this scheme. Show the beginning of the decode array, that is, covering the first three codes, using ... for repetitive entries as in the notes.
Explanation / Answer
Step1 )Creating Huffman Tree answers a,b
Step2)General code to do all thing
}
import java.util.ArrayList;Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.