GATE Computer ScienceVery hardGATE CS (PYQ pattern)
Ten symbols with frequencies 2, 3, 4, 5, 6, 8, 10, 15, 20, 27 (total 100) are encoded with an optimal ternary (3-ary) Huffman code, whose codewords use digits 0, 1, 2. What is the total length of the encoded message in ternary digits?
- A. 228
- B. 295
- C. 186
- D. 192
Correct answer: D. 192
A full ternary tree needs (n − 1) divisible by 2, so one dummy symbol of frequency 0 is added (11 leaves). Merging three smallest each time: (0,2,3)=5, (4,5,5)=14, (6,8,10)=24, (14,15,20)=49, (24,27,49)=100. Total = 5 + 14 + 24 + 49 + 100 = 192. Merging without the dummy gives 228; 295 is the binary Huffman length.
More Algorithms questions
- Eight files of sizes 4, 7, 9, 12, 15, 18, 22 and 25 are merged using 3-way merges (merging any 3 files costs the sum of their sizes; merge…
- Which of the following statements about Huffman coding on a set of symbols with positive frequencies is/are correct? I. If f(a) > f(b)…
- Intervals (start, end, weight) are (0,3,4), (1,5,6), (2,6,10), (5,8,7), (4,9,9), (7,10,3), (9,12,8), (8,13,5), (12,15,6), (10,16,12); two…
- Ten unit-time jobs have (deadline, profit): (2,95), (1,60), (2,40), (3,85), (3,30), (1,25), (4,70), (2,20), (4,55), (5,15). Each job takes…
- Seven keys have search probabilities (in percent, in sorted key order) 18, 6, 22, 14, 4, 20, 16 and only successful searches occur. The…
- The egg-drop puzzle: a building has 100 floors, and you have 3 identical eggs. An egg that is dropped from a floor at or above the…