Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Assignment #5 DUE 11 p.m Write a program to implement Huffman coding and decoding (see pages 415-421) in Java. NO LATE ASSIGNMENTS ACCEPTED PLEASE The

image text in transcribed

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

Assignment #5 DUE 11 p.m Write a program to implement Huffman coding and decoding (see pages 415-421) in Java. NO LATE ASSIGNMENTS ACCEPTED PLEASE The program's input will be a command line file that can contain any char, but the only ones of interest in this assignment are the capital letters A through G A COMMAND LINE FILE IS JUST THAT: A FILE NAME THAT IS ENTERED ON THE COMMAND LINE (you will use jGrasp with build/run args) PRIOR TO RUNNING THE PROGRAM. Read the file char by char. IF the file happens to contain chars other than A through G IGNORE THEM in a-d Spaces should be ignored , for example , as should other chars! You may assume that each of A through G are in the file I want you to display (all answers MUST go to the console) using a menu system (from the console OR from a window): a. The Huffman tree (see page 405 and 418itself (you may use the code from Tree.java if you wish.) You may assume that the tree will turn out to be no deeper than the tree shown on page 405 You may also assume that no individual char appears more than 9 times. Print either a char or a weight depending upon whether the node is a leaf or not. The Huffman tree can be constructed using a priority queue. Exercise OPTION a before other options. b. the code table that displays the encoding for each of the chars A through G (see page 416-417.) EXERCISE OPTION b after OPTION a. c. the binary encoding of the portion of the file that only contains the chars A through G (after each eight bits leave a space and print only 3 bytes per line.) The binary encoding may not necessarily display a "full" byte at the end (see page 417.) Exercise OPTION c after OPTION b d. the A-G portion of the original file that is calculated by using the HUFFMAN TREE from part a and the binary encoding from part c (don't just print the file back from the original; you must use the HUFFMAN TREE to do this) So you want to "read" the binary encoding from part c (using the HUFFMAN TREE from part a to reconstruct the portion of the file that consists of A through G. BASICALLY YOU ARE DEOCODING THE PORTION OF THE FILE THAT CONSISTS OF THE CHARS A-G AS YOU READ THE ENCODED FILE YOU ARE MARCHING DOWN THE HUFPMAN TREE--WHEN YOU REACH A LEAF, YOU CAN FIGURE OUT WHICH CHAR IT IS AND YOU PRINT THAT CHAR. Exercise OPTION d after OPTION c. Same rules as other programs. I will use jGrasp. One file only. Name it correctly

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

What are the arguments for and against an independent Fed?

Answered: 1 week ago