Answered step by step
Verified Expert Solution
Question
1 Approved Answer
dont use chat gpt - Problem 1 : The Decoding Ta ble Write a C program in main . c in directory unzipper that will
dont use chat gpt Problem : The Decoding Ta
ble
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.
Examples
Input Ex Output Ex Input Ex Output Ex
inputEx
xa
xxx
xxx
xxx
xc xx
xf xx
xa xa x
xxc x
xxd x
xxe x
xxf x
xxxx
OutputEx
x :
x :
x :
xc :
xf :
xa :
x :
x :
x :
x :
InputEx
xd
xb xx
xa xx
xxc x
xxe x
xxf x
xa xf x
xxcf xc
xxcf xc
xxbf xc
xxaf xc
xxf xc
xxf xd
xxf xe
xxxx
OutputEx
xb :
xa :
x :
x :
x :
xa :
x :
x :
x :
x :
x :
x :
x :
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