Similar questions 3 more →
Greedy Algorithms

Answer & solution
Official answer: B
The frequencies are 1, 2, 2, 2, 3. Huffman merging costs are 3, 4, 6, 10, totaling 23 bits, the optimal weighted path length. The dictionary tie rule can also be met: assign b=00, c=01, e=10, a=110, d=111. Then lengths of b, c, d are 2, 2, 3, and total length is 3+4+4+6+6=23. Thus B.
Huffman repeatedly merges the two smallest available weights: 1+2=3; 2+2=4; 3+3=6; 4+6=10. Each merge adds its weight once to the encoded length because all leaves below it gain one bit. The displayed code is prefix-free and satisfies the alphabetical tie restriction, so the unrestricted Huffman lower bound is attainable with the extra condition.








![Question 84a, GATE 2005: Nine unit-time jobs T1…T9, one at a time, earn profits[15, 20, 30, 18, 18, 10, 23, 16, 25] if finished by deadlines[7, 2, 5, 3, 4, 5, 2, 7, 3], respectively. Printed 84(a): in a maximum-profit schedule A all jobs done; B T1, T6 omitted; C T1, T8 omitted; D T4, T6 omitted.](../../../assets/questions/CS-2005-Q87-1.webp)
![Question 84a, GATE 2005: Nine unit-time jobs T1…T9, one at a time, earn profits[15, 20, 30, 18, 18, 10, 23, 16, 25] if finished by deadlines[7, 2, 5, 3, 4, 5, 2, 7, 3], respectively. Printed 84(a): in a maximum-profit schedule A all jobs done; B T1, T6 omitted; C T1, T8 omitted; D T4, T6 omitted.](../../../assets/questions/CS-2005-Q87-2.webp)
![Question 84a, GATE 2005: Nine unit-time jobs T1…T9, one at a time, earn profits[15, 20, 30, 18, 18, 10, 23, 16, 25] if finished by deadlines[7, 2, 5, 3, 4, 5, 2, 7, 3], respectively. Printed 84(a): in a maximum-profit schedule A all jobs done; B T1, T6 omitted; C T1, T8 omitted; D T4, T6 omitted.](../../../assets/questions/CS-2005-Q87-3.webp)
![Question 84b, GATE 2005: Nine unit-time jobs T1…T9, one at a time, earn profits[15, 20, 30, 18, 18, 10, 23, 16, 25] if finished by deadlines[7, 2, 5, 3, 4, 5, 2, 7, 3], respectively. Printed 84(b): maximum profit A147; B165; C167; D175.](../../../assets/questions/CS-2005-Q88-1.webp)
![Question 84b, GATE 2005: Nine unit-time jobs T1…T9, one at a time, earn profits[15, 20, 30, 18, 18, 10, 23, 16, 25] if finished by deadlines[7, 2, 5, 3, 4, 5, 2, 7, 3], respectively. Printed 84(b): maximum profit A147; B165; C167; D175.](../../../assets/questions/CS-2005-Q88-2.webp)
![Question 84b, GATE 2005: Nine unit-time jobs T1…T9, one at a time, earn profits[15, 20, 30, 18, 18, 10, 23, 16, 25] if finished by deadlines[7, 2, 5, 3, 4, 5, 2, 7, 3], respectively. Printed 84(b): maximum profit A147; B165; C167; D175.](../../../assets/questions/CS-2005-Q88-3.webp)

