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 1: 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 T in the decoding table. This byte is to be interpreted as an unsigned integer. If T is 0, then it is to
be interpreted as 256. This is followed by T lines, each encoding a table entry and consisting of three
items: the character, C, that is encoded; the length, L,(in bits) of the
encoding; and the encoding, E, which is bit sequence of L bits. After
the table entries there are four bytes encoding the length of the com-
pressed bitstream to be decoded. For Problem 1, these four bytes are
0, indicating there is no compressed data to follow. In Problem 2,
these four bytes will not be all 0 s.
Each entry is encoded as a three byte (24-bit) bitstream, where the bits
in each byte are ordered most-significant (first bit) to least significant
(last bit). The first 8 bits encode the character (C). The next 4 bits en-
code length, L(an unsigned integer), and the first L bits of the remain-
ing 12 bits are the compressed encoding E, of character C. 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
8x. 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 2 and 4 bits long instead of the full 8 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 256 entries. (Use an array
of structs to store the table, as it will be needed for Problem 2.)
For each entry, read in the 3 bytes and interpret the 24-bit bit-
stream as described above.
The encoding of each character will be at most 12 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 T lines, one line per entry in the table. Each line should be terminated by a new-line character. The
entries should be displayed in the same order as the input.
Each entry has the following format:
C:LE2
where
C is the character in hexadecimal using the format "0x82.2x"
L is a decimal integer, using the format "8d"
E2 is the binary representation of the encoding, it should be exactly L characters (0 s and {:1(s)) long.
 Problem 1: The Decoding Table Write a C program in main

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!