eish am strugling with this binary tree.huffman code and i ave an assignment,have a look on that

You are given a text file. Any printable character, including digits and punctuation can be present in
the file. Newlines and blank spaces can be present as well. Your job is to write a program that
processes this file and produces a table which lists all the characters in the file, their frequencies and
their Huffman codes.
1. You may use any priority queue implementation, including the one provided by Java.
2. Bitwise operations may prove tedious. Instead of generating real bit codes, simulate them
using the characters '0' and '1'. The result will not be real compression, therefore. But it
should simplify the program so that you concern yourself with the data structures, not the
3. You are not required to produce a full Huffman compression/uncompression utility. Once
the codes are produced, your work is done. The main task, therefore, is implementing the
Huffman algorithm, which requires the character frequencies and thus implies the first task.
Results are to be displayed in the following format
Character frequency code
compression rate
This is given by (x–y) / x, where
x is the number of bits in the input file
y is number of bits in the compressed file
Note: you do not need to compress the file to know y!
For example, the output below shows that d appeared 19 times, the semi­colon 50 times and the
number 7 appeared twice, and so on. The Huffman tree then produced the corresponding code for
each character. Indicate a newline as nl and a blank space as sp. The last line of output is the
compression rate.
d 19 00110
; 50 100
7 2 1011100101
nl 95 010
sp 200 11

Recommended Answers

May I see your code that you have done so far?

Jump to Post

All 2 Replies

May I see your code that you have done so far?

dont even know where to start

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.