Question: Java Program. Using the frequency table shown below, build a Huffman Encoding Tree. Resolve ties by giving single letter groups precedence (put to the left)

Java Program. Using the frequency table shown below, build a Huffman Encoding Tree. Resolve ties by giving single letter groups precedence (put to the left) over multiple letter groups, then alphabetically. Do not worry about punctuation or capitalization.

For this lab only, you may use string methods to work with the groups of letters. This program will need to be able to read three different files: a file containing the frequency table, a file containing clear text to be encoded and a file containing encoded strings.

Print out the tree by doing a preorder traversal. Print the resulting encoding generated by the tree. An example is given below for a 3-letter alphabet. You may use any reasonable format to print the encoding. X 3 The tree in preorder is: XYZ: 6, X: 3, YZ: 3, Y: 1, Z: 2 Y 1 Z 2 The code is X = 0; Y = 10, Z = 11;

In your write-up, consider whether you achieved any useful data compression with this method. Compare to conventional encoding. How would your results be affected by using a different scheme to break ties, for example, if you had given precedence to alphabetical ordering and then to the number of letters in the key? What other structures did you use and why? Encode the strings in the supplied ClearText.txt file, plus several others of your choice: Decode the strings the supplied Encoded.txt file, plus some others of your choice: Use the frequency table in the supplied FreqTable.txt file. Consider experimenting with other frequency tables. As a check, here is a simple string in clear text and encoded form. Hello World 1101101000010001111100011111101000000101100

FreqTable.txt file contains:

A - 19 B - 16 C - 17 D - 11 E - 42 F - 12 G - 14 H - 17 I - 16 J - 5 K - 10 L - 20 M - 19 N - 24 O - 18 P - 13 Q - 1 R - 25 S - 35 T - 25 U - 15 V - 5 W - 21 X - 2 Y - 8 Z - 3 

Encoded.txt file contains:

01011001010110011111011011 10110000101010011011101101100010110010101100010111000110111 11111110001000111111101011111011001111111000100011111000001010000001110010111 

ClearText.txt file contains:

Sally sells seashells by the seashore. Peter Piper picked a peck of pickled peppers a peck of pickled peppers Peter Piper picked. Houston, the Eagle has landed. Is that your final answer?

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!