Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

we want to compress more if possible. To do this, we take advantage of the fact that characters do not usually occur with the same

we want to compress more if possible. To do this, we take advantage of the fact that
characters do not usually occur with the same frequency in a text. We now want to encode the characters
in such a way that
we use short bit sequences for frequent characters and then disproportionately long bit sequences for rare
characters. We choose a simple division for this. A bit sequence is always a character if the number of bits
is odd and has a 0 at the end. However, this also means that 0s can otherwise only occur in even
positions. This results in a unique coding, even if all bit sequences are simply added one after the other.
This results in the following possible bit sequences, listed in order of length from left to right and top to
bottom. coded.
0
100110
10100101101110011110
10101001010110101110010111101110100...
....
We can see that we can display one character with one bit, two characters with three bits, four characters
with five bits, eight characters with seven bits, 16 characters with nine bits, 32 characters with 11 bits and
64 characters with a maximum of 13 bits.
We now need to specify the characters in the compressed file at the beginning in their order of frequency.
We start with a byte that specifies the number of occurring characters, then with all characters, one per
byte, in the order sorted by frequency, if it occurs. This is followed by the character-by-character
translated text with bit patterns of different lengths. We end with 1-en if there is still room, otherwise we
would always have the most frequent character at the end.
To implement the possible bit patterns from above, you can work with a vector> as a work
queue. You take out a bit pattern at the beginning and delete it. If the bit pattern is odd long and has a 0 at the
end, then add it to the bit patterns for translated characters. If not, then add a bit pattern like the extracted
one with an additional 0 at the end and one like the extracted one with an additional 1 at the end. Do this until
you have a sufficient number of bit patterns. Bit patterns of length 13 inclusive are sufficient. please explain this task further and more deeply

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases Illuminated

Authors: Catherine Ricardo

2nd Edition

1449606008, 978-1449606008

More Books

Students also viewed these Databases questions