Question
Huffman Coding. a) Huffman coding assigns unique binary codes to replace characters within a string. An encoding binary tree may be built using an adapted
Huffman Coding. a) Huffman coding assigns unique binary codes to replace characters within a string. An encoding binary tree may be built using an adapted Greedy Method: starting with the frequency of each element as sorted single-node trees, the 2 minimum weight trees are chosen, merged, then returned to the selection pool, until a single remaining tree results. The trees are sorted based on their weights; then by a tie breaker. Tree weights are the sum of their leaves frequency. (Surprisingly, the greatest compression results from unbalanced trees.) Determine the frequency of each letters use in the William Shakespeare quote, A ROSE BY ANY OTHER NAME WOULD SMELL AS SWEET without the quote marks or spaces. The tie breaker is that letters are ranked alphabetically. Show building the tree, step by step. b) After constructing the tree, each letters code is constructed by a walk from the root to each leaf: a 0 is assigned to each left child node on each level below the root, while a 1 is assigned to each right child node, including interior nodes. (Example: in a tree with 3 levels below the root, a LRR leaf, from top-down, would be encoded as a 011) Encode the letters used in the phrase. Give the encoded version (0s & 1) streamed for the entire phrase. (Note: the letter codes should be unique such that as soon as 011 is read from the stream, it is known to correspond to a particular letter; thus there would not be a 01101 code assigned in this tree.) c) Encode the same phrase using ASCII and compare the sizes of the generated strings of bits, (b) & (c).?
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started