GATE CS 2021 Set 2 | Question 36

Algorithms › Algorithm Design Techniques · MCQ · 2 marks · Answer: B

  1. Question 36Algorithmsmcq2 marks
    Consider the string abbccddeee. Each letter in the string must be assigned a binary code satisfying the following properties: 1. For any two letters, the code assigned to one letter must not be a prefix of the code assigned to the other letter. 2. For any two letters of the same frequency, the letter which occurs earlier in the dictionary order is assigned a code whose length is at most the length of the code assigned to the other letter. Among the set of all binary code assignments which satisfy the above two properties, what is the minimum length of the encoded string?
    • A.
      21
    • B.
      23
      ✓
    • C.
      25
    • D.
      30

    Answer: B

    Solution

    Frequencies: . Building an optimal prefix (Huffman) code and summing (frequency code length) gives the minimum total length of 23 bits.

More GATE PYQ on Algorithm Design Techniques

All GATE CS Algorithms PYQ →

Attempt GATE CS 2021 Set 2 in real GATE exam mode

Full paper with a timer, the GATE interface and a topic-wise analysis — free.

Create free account →