Skip to content
GATEiit

GATE CSE 2017 Session 2 Q60: Expected Huffman-encoded length of a 100-character message

Syllabus topic: Algorithm design techniques: greedy, dynamic programming and divide-and-conquer

Question

A message is made up entirely of characters from the set X={P,Q,R,S,T}. The table of probabilities for each of the characters is shown below:

CharacterProbability
P0.22
Q0.34
R0.17
S0.19
T0.08
Total1.00

If a message of 100 characters over X is encoded using Huffman coding, then the expected length of the encoded message in bits is ________.

Try it: numerical answer: type the value

Numerical answer. No negative marking.
Show answer and explanation

Answer: 225 (official GATE 2017 final answer key)

Concept used: Huffman coding repeatedly merges the two least probable symbols; expected length is ∑piℓi per character, times the message length.

Concept notes

Loading notes…

First step: Build the Huffman tree by merging T and R first, find each character's code length, and compute the average bits per character.

Full step-by-step solution

Loading…

Answer from the official final answer key. Found a mistake? Use Report issue and we will fix it.

More questions on Algorithm design techniques: greedy, dynamic programming and divide-and-conquer

Every PYQ on this topic →

Share this question

WhatsAppDownload image

Source: official GATE 2017 Session 2 CS question paper and final answer key, organised by IIT Roorkee. Question paper · Answer key