Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I need help with writing a Huffman code encoder, specifically in c++. You are required to write a Huffman code encoder. Details: Name your program
I need help with writing a Huffman code encoder, specifically in c++.
You are required to write a Huffman code encoder. Details: Name your program as hmencoder. Usage of hmencoder: hmencoder [input_file] where input_file is the file containing the input message. The input message contains normal English text. You need to encode all English letters together with all printable characters such as ., ;", "!", space etc. The capital letter and the corresponding small letter are treated as two symbols. For example, "A" and "a" are regarded as two symbols. Here we don't consider carriage return. In other words, you only need to consider the characters from "space" to ">" in the ASCII table. The output of hmencoder should have two output files, "code.txt" and "encodemsg.txt". The output file code.txt stores the codeword for each symbol and the average number of bits used for each symbol. The format of this output file is as follows: Each row contains the codeword for a separate symbol, the symbols are listed according to the increasing order of the corresponding ASCII code value. The last row shows the average number of bits used for each symbol. E.g. Space: 000 !: 001 A: 0100 z: 1000 Ave = 3.43 bits per symbol The output file "encodemsg.txt" stores the encoded message with 80 0/1 characters on each row (except the last row). You are required to write a Huffman code encoder. Details: Name your program as hmencoder. Usage of hmencoder: hmencoder [input_file] where input_file is the file containing the input message. The input message contains normal English text. You need to encode all English letters together with all printable characters such as ., ;", "!", space etc. The capital letter and the corresponding small letter are treated as two symbols. For example, "A" and "a" are regarded as two symbols. Here we don't consider carriage return. In other words, you only need to consider the characters from "space" to ">" in the ASCII table. The output of hmencoder should have two output files, "code.txt" and "encodemsg.txt". The output file code.txt stores the codeword for each symbol and the average number of bits used for each symbol. The format of this output file is as follows: Each row contains the codeword for a separate symbol, the symbols are listed according to the increasing order of the corresponding ASCII code value. The last row shows the average number of bits used for each symbol. E.g. Space: 000 !: 001 A: 0100 z: 1000 Ave = 3.43 bits per symbol The output file "encodemsg.txt" stores the encoded message with 80 0/1 characters on each row (except the last row)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