1.8 Huffman compression Flashcards
What is the basic idea of compression?
To encode frequently-occurring items using fewer bits.
How many bits does uncompressed ASCII characters use?
8 bits each.
Compress the text ‘AAA Go’ using Huffman coding.
0 0 0 10 110 111.
How many bits does the compressed version of ‘AAA Go’ use?
11 bits.
What does the dictionary in Huffman compression do?
It assigns shorter codes to frequent items.
What is the compressed code for the ASCII string ‘00000000 00000000 11111111 00000100’ using the given dictionary?
00 00 01 111.
Is any code in the provided dictionary a prefix of another code?
No.
What is the output for decompressing the code ‘00 01 00’?
00000000 11111111 00000000.
What is a character frequency table?
A table that contains each distinct character from the input string and each character’s number of occurrences.
What does the pseudocode ‘BuildCharacterFrequencyTable’ do?
It builds a frequency table for characters in an input string.
What character frequency is assigned to the letter ‘A’ in the string ‘APPLES AND BANANAS’?
5.
What is Huffman coding?
A common compression technique that assigns fewer bits to frequent items using a binary tree.
What is the first step in Huffman coding?
Determine the frequencies of each item.
What is the compressed output for the text ‘aabbbaaccd’ using Huffman coding?
0 0 10 10 10 0 0 110 110 111.
How is the encoding for each leaf node obtained in Huffman coding?
By traversing from the top node to the leaf, appending 0 for left branches and 1 for right branches.
Fill in the blank: Prior to compression, a _______ must be built for an input string.
character frequency table.
What occurs when a character appears for the first time in the frequency table?
Its frequency is set to 1.
What happens to the frequency of a character when it appears again in the frequency table?
The existing frequency is incremented.
What is the total frequency count of the string ‘seems he fleed’ for the letter ‘e’?
3.
True or False: In Huffman coding, the merging of nodes continues until only one node exists.
True.
What is the first merge in Huffman coding for the frequencies D: 3 and E: 3?
D and E: 6
This merge yields the smallest sum: 3 + 3 = 6.
What is the second merge in Huffman coding after merging D and E?
DE and B: 10
DE is 6 (from the first merge). B is 4. So 6 + 4 = 10.
What is the third merge in Huffman coding after DE and B?
DEB and C: 50
DEB is 10 (from the second merge). C is 40. So 10 + 40 = 50.
What is the fourth merge in Huffman coding after DEB and C?
DEBC and A: 100
DEBC is 50 (from the third merge), and A is 50. So 50 + 50 = 100.