GATE Assistant

Past questions › Computer Science and Information Technology › GATE 2021 set2

GATE 2021 set2 · CS · MCQ · 2 marks · Algorithms › Greedy Algorithms

GATE 2021 set2 Computer Science and Information Technology question: Consider the string abbccddeee. Each letter in the string must be assigned a binary code…

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?

  1. (A)

    21

  2. (B)

    23

  3. (C)

    25

  4. (D)

    30

Show answer

Official answer: B

Practise this question with exam-style marking

Discussion

No discussion yet.

Join the discussion