Skip to content
Related Articles

Related Articles

Improve Article
GATE | GATE CS 2021 | Set 2 | Question 36
  • Last Updated : 23 May, 2021

Consider the string abbccddeee. Each letter in the string must be assigned a binary code satisfying the following properties:

  • For any two letters, the code assigned to one letter must not be a prefix of the code assigned to the other letter.
  • 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)


Alphabet      Frequency
a                1
b                2
c                2
d                2
e                3

Required answer, 

= 1×3 + 2×3 + 3×2 + 2×2 + 2×2 
= 23 

Correct Option B

Quiz of this Question

Attention reader! Don’t stop learning now. Learn all GATE CS concepts with Free Live Classes on our youtube channel.

My Personal Notes arrow_drop_up
Recommended Articles
Page :