ISRO Scientist/Engineer CSE 2020Algorithms › Not yet assigned to a topic
ISRO Scientist/Engineer CSE 2020 PYQ: Huffman tree is constructed for the following data :$\{A,B,C,D,E\}$ with frequency $\{0.17,0.11,0.24,0.33\…
Huffman tree is constructed for the following data :$\{A,B,C,D,E\}$ with frequency $\{0.17,0.11,0.24,0.33\ \text{and} \ 0.15 \}$ respectively. $100\ 00\ 01101$ is decoded as
- A$BACE$Correct answer
- B$CADE$
- C$BAD$
- D$CADD$
Answer
(A) $BACE$
Approach
Frequencies: A=0.17, B=0.11, C=0.24, D=0.33, E=0.15. Building the Huffman tree by repeatedly merging the two smallest frequencies: merge B(0.11)+E(0.15)=0.26; merge A(0.17)+C(0.24)=0.41; merge 0.26+D(0.33)=0.59; merge 0.41+0.59=1.00. The attached tree diagram confirms this structure: root 1.00 splits into 0.41 (left, edge 0) and 0.59 (right, edge 1); 0.41 splits into A (edge 0) and C (edge 1); 0.59 splits into 0.26 (edge 0) and D (edge 1); 0.26 splits into B (edge 0) and E (edge 1). Reading codes from root to leaf: A=00, C=01, B=100, E=101, D=11. This is a valid prefix-free code. Now decode the given bit string. Ignoring the cosmetic spacing, the string is 1000001101. Greedily parsing with the codes: '100' matches B, then '00' matches A, then '01' matches C, then the remaining '101' matches E. This consumes all ten bits ('100'+'00'+'01'+'101' = 1000001101), giving the decoded sequence B-A-C-E, i.e., BACE. Checking the other options: CADE would require the string to start with C (01) rather than B (100); BAD would leave bits unconsumed and does not correspond to any valid full parse; CADD likewise mismatches the first three bits. Note that the primary solver arrived at the same correct answer but with slightly muddled intermediate codewords (it listed D=1, which is not prefix-free with B=100); the image tree correctly gives D=11. However, since D never appears in the encoded string, the final decode is unaffected and BACE remains correct, matching option A.
Reviewed by ISRO IQ Editorial Team.