Recall & Review
beginner
What is Huffman Encoding?
Huffman Encoding is a way to compress data by using shorter codes for common letters and longer codes for rare letters. It builds a tree to assign these codes so the total size is smaller.
Click to reveal answer
beginner
What data structure is mainly used in Huffman Encoding?
A binary tree called the Huffman Tree is used. It helps assign codes to characters based on their frequency.
Click to reveal answer
intermediate
How are the codes assigned in Huffman Encoding?
Codes are assigned by traversing the Huffman Tree: going left adds '0' and going right adds '1'. Leaves represent characters with their codes.
Click to reveal answer
intermediate
Why does Huffman Encoding produce a prefix code?
Because no code is the start of another code, so decoding is easy and unambiguous. This happens naturally from the tree structure.
Click to reveal answer
advanced
What is the time complexity to build a Huffman Tree for n unique characters?
It is O(n log n) because we use a priority queue to pick the two smallest frequencies repeatedly until one tree remains.
Click to reveal answer
What does Huffman Encoding use to decide code lengths?
✗ Incorrect
Huffman Encoding assigns shorter codes to characters that appear more often, based on their frequency.
In Huffman Tree, what does a leaf node represent?
✗ Incorrect
Leaf nodes represent actual characters with their assigned codes.
What is the first step in building a Huffman Tree?
✗ Incorrect
We start by creating leaf nodes for each character with their frequency.
Why is Huffman Encoding called a lossless compression?
✗ Incorrect
Huffman Encoding allows exact recovery of original data, so no information is lost.
Which data structure helps efficiently pick the two smallest frequencies in Huffman Encoding?
✗ Incorrect
A priority queue or min-heap helps pick the two smallest frequency nodes quickly.
Explain how Huffman Encoding builds the tree and assigns codes to characters.
Think about combining smallest frequencies step by step.
You got /5 concepts.
Why is Huffman Encoding efficient for data compression compared to fixed-length codes?
Consider how code length relates to character frequency.
You got /5 concepts.