Starting from:
$35

$29

Huffman Codes Solution

Write a program that takes any input text and produces both a frequency table and the corresponding Huffman code.




 
Take approximately 360 words from any English document as your input text. Ignore all blanks, all punctuation marks, all special symbols. Create an input file with this input text.

 
Construct the frequency table according to the input text read from the file:




 
The frequency's must be listed, in order, from largest (at the top) to smallest (at the bottom)




 
Then, using the Huffman algorithm, construct the optimal prefix binary code for the table.




 
The Huffman codes will be sorted in the same manner as the one above i.e. frequency, highest to lowest.




 
Design your program to read the input from the input file "infile.dat". Your program must produce the output, in the file "outfile.dat",(Files must be named "infile.dat" and "outfile.dat" consisting of

 
the frequency table for the source text,




 
the Huffman code for each letter and digit in the source code, and




 
the length of the coded message in terms of number of bits,




Final Output (Example Values Not Accurate)




Symbol frequency




A,
15%
m,
11%
7,
6%
Symbol Huffman


Codes
A,
10101
m,
1101
7,
111



Total Bits: 16005







Note: You must not submit your "node_modules" folder if you are working on NodeJs/JavaScript. (Just submit your JavaScript source code and package.json file)







Huffman Coding












Criteria
Ratings
Pts








Prompt user for input file path (if no input from user, assume path: current working directory, file-name: infile.dat)
5.0 pts
0.0 pts


Full
No
5.0 pts




Marks
Marks










Prompt user for output file path. Purge file if exists already, or delete existing contents before writing. (if no input from user, assume
5.0 pts
0.0 pts


Full
No
5.0 pts
path: current working directory, file-name: outfile.dat)
Marks
Marks












Read text from input file. (Ignore blanks, punctuation and symbols while parsing)
10.0 pts
0.0 pts


Full
No
10.0 pts




Marks
Marks










Generate frequency table for every symbol in input text. Write frequency table to output file (in DESC order of frequency) (-5 points for
15.0 pts
0.0 pts


Full
No
15.0 pts
round off values).
Marks
Marks












Generate Huffman codes for every symbol in input text and write to output file (in DESC order of frequency). If frequency table is
20.0 pts
0.0 pts


Full
No
20.0 pts
incorrect, points will be lost on this criterion.
Marks
Marks












Encoding follows Huffman logic: Most frequent symbol has the smallest binary code. If frequency table is incorrect, points will be lost
20.0 pts
0.0 pts


Full
No
20.0 pts
on this criterion.
Marks
Marks












Compute length of coded message in terms of Huffman codes. Write this to output file. If frequency table and/or Huffman codes are
10.0 pts
0.0 pts


Full
No
10.0 pts
incorrect, points will be lost on this criterion -5 points, incorrect bits calculation).
Marks
Marks












Code style (selection of apt data structures, code efficiency, error checking, etc.)
10.0 pts
0.0 pts


Full
No
10.0 pts




Marks
Marks










Output file formatted for easy reading: Tables displayed as matrix, spacing between distinct items (frequency-table, code-table, length
5.0 pts
0.0 pts


Full
No
5.0 pts
of encoded text), etc.
Marks
Marks












Late submission penalty per policy
0.0 pts
0.0 pts


Full
No
0.0 pts




Marks
Marks













Total Points: 100.0















































More products