Q8.Marks: +2.0UGC NET Paper 2: Computer Science and Application 26th June 2025 Shift 1
The correct sequence of constructing Huffman tree is
A. Repeat until root formed
B. Create leaf nodes
C. Build priority queue
D. Combine lowest frequency nodes
Choose the correct answer from the options given below:
1.B ,C,A,D
2.D ,B,A,C
3.B ,C,D,A✓ Correct
4.C ,A,B,D
Solution
The correct answer is option 3
Key Points
To construct a Huffman tree, the following steps are followed in a specific sequence:
Step 1: Create leaf nodes (B) - Each character with its frequency is represented as a leaf node.
Step 2: Build priority queue (C) - The leaf nodes are inserted into a priority queue (min-heap) based on their frequencies.
Step 3: Combine lowest frequency nodes (D) - The two nodes with the lowest frequencies are combined to form a new node, and the sum of their frequencies is assigned to it. This new node is reinserted into the priority queue.
Step 4: Repeat until root formed (A) - Steps 2 and 3 are repeated until only one node (the root) remains in the priority queue, which represents the Huffman tree.
Additional Information
The priority queue ensures that the nodes with the smallest frequencies are always selected first for combination, which is essential for constructing the optimal Huffman tree.
The Huffman tree is used in data compression algorithms to assign variable-length binary codes to characters based on their frequencies, resulting in efficient encoding.
Sequence: B (Create leaf nodes) → C (Build priority queue) → D (Combine lowest frequency nodes) → A (Repeat until root formed)