Question: Problem 1 : The Decoding Table Write a C program in main . c in directory unzipper that will be compiled into an executable unzip
Problem : The Decoding Table
Write a C program in main c in directory unzipper that will be compiled into an executable unzip
per. Your program will read in a series of bytes in hexadecimal notation, representing the decoding table
needed to decompress a piece of compressed text.
Input
Your program will read its input from stdin. The first line contains a single byte denoting the number of
entries in the decoding table. This byte is to be interpreted as an unsigned integer. If is then it is to
be interpreted as This is followed by lines, each encoding a table entry and consisting of three
items: the character, that is encoded; the length, in bits of the
encoding; and the encoding, which is bit sequence of bits. After
the table entries there are four bytes encoding the length of the com
pressed bitstream to be decoded. For Problem these four bytes are
indicating there is no compressed data to follow. In Problem
these four bytes will not be all s
Each entry is encoded as a three byte bit bitstream, where the bits
in each byte are ordered mostsignificant first bit to least significant
last bit The first bits encode the character The next bits en
code length, an unsigned integer and the first bits of the remain
ing bits are the compressed encoding of character The three
bytes are encoded in the input in hexadecimal. Hint: Use scanf to
read the bytes For the hexadecimal, use the format specifier with
On the right is an example of a table for encoding the string
"Hello World!
Observe that in this case the encodings for the
characters are between and bits long instead of the full bits per
byte.
Processing
Your program will need to read in the table and output it in a human
readable form.
The decoding table will have at most entries. Use an array
of structs to store the table, as it will be needed for Problem
For each entry, read in the bytes and interpret the bit bit
stream as described above.
The encoding of each character will be at most bits. Any extra bits can be ignored.
Output
All output should be performed to stdout. The output must be exactly as specified. The output consists
of lines, one line per entry in the table. Each line should be terminated by a newline character. The
entries should be displayed in the same order as the input.
Each entry has the following format:
:
where
is the character in hexadecimal using the format
is a decimal integer, using the format
is the binary representation of the encoding, it should be exactly characters s and : long.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
