Skip to main content

Huffman coding of "Engineer Ko Betha Arulai Ke Thaha"

Short answer

Huffman coding on 33 symbols gives entropy 3.542 bits/symbol, average length 3.576 bits/symbol, efficiency 99.05%. For 'Engineer Ko Betha Ke Ke', substitute symbols from code table: e=000, n=1010, g=01110, i=1100, etc., producing a 83‑bit codeword.

Encode "Engineer Ko Betha Arulai Ke Thaha" using Huffman Encoder and calculate the transmission efficiency. Find the codeword if the message is received as "Engineer Ko Betha Ke Ke".

Assumptions: upper and lower case are treated as the same letter, and the space is counted as a symbol because it must also be sent. The message "engineer ko betha arulai ke thaha" has 33 symbols, with 14 distinct symbols.

Huffman encoding

Huffman procedure: list the symbols by probability. Repeatedly combine the two least probable entries into one node whose weight is their sum, until only one node is left. In each merge, the first group listed gets bit 0 and the second group gets bit 1. Each symbol's code word is read from the root down to that symbol.

Merge steps (weights are counts out of 33):

  1. {g} (1) + {b} (1) → 2
  2. {o} (1) + {l} (1) → 2
  3. {i} (2) + {u} (1) → 3
  4. {n} (2) + {k} (2) → 4
  5. {t} (2) + {r} (2) → 4
  6. {o, l} (2) + {g, b} (2) → 4
  7. {i, u} (3) + {h} (3) → 6
  8. {t, r} (4) + {n, k} (4) → 8
  9. {space} (5) + {o, l, g, b} (4) → 9
  10. {e} (5) + {a} (5) → 10
  11. {t, r, n, k} (8) + {i, u, h} (6) → 14
  12. {e, a} (10) + {space, o, l, g, b} (9) → 19
  13. {e, a, space, o, l, g, b} (19) + {t, r, n, k, i, u, h} (14) → 33
SymbolCountpip_iCodelil_ipilip_i l_i
space55/33 = 0.151501030.4545
a55/33 = 0.151500130.4545
e55/33 = 0.151500030.4545
h33/33 = 0.090911130.2727
i22/33 = 0.0606110040.2424
k22/33 = 0.0606101140.2424
n22/33 = 0.0606101040.2424
r22/33 = 0.0606100140.2424
t22/33 = 0.0606100040.2424
b11/33 = 0.03030111150.1515
g11/33 = 0.03030111050.1515
l11/33 = 0.03030110150.1515
o11/33 = 0.03030110050.1515
u11/33 = 0.0303110140.1212

Average code length:

Lˉ=∑pili=11833=3.5758 bits/symbol\bar L = \sum p_i l_i = \frac{118}{33} = 3.5758\ \text{bits/symbol}

Here the numerator is the total number of bits in the encoded message: 5(3)+5(3)+5(3)+3(3)+2(4)+2(4)+2(4)+2(4)+2(4)+1(5)+1(5)+1(5)+1(5)+1(4)=1185(3) + 5(3) + 5(3) + 3(3) + 2(4) + 2(4) + 2(4) + 2(4) + 2(4) + 1(5) + 1(5) + 1(5) + 1(5) + 1(4) = 118 bits.

Entropy:

H=−∑pilog⁡2pi=3.5419 bits/symbolH = -\sum p_i \log_2 p_i = 3.5419\ \text{bits/symbol}

Efficiency:

η=HLˉ=3.54193.5758=0.9905=99.05%\eta = \frac{H}{\bar L} = \frac{3.5419}{3.5758} = 0.9905 = 99.05\%

Redundancy =1−η=0.95%= 1 - \eta = 0.95\%.

A fixed-length code for 14 symbols needs ⌈log⁡214⌉=4\lceil \log_2 14 \rceil = 4 bits/symbol (η=88.55%\eta = 88.55\%). Huffman saves 10.61% of the bits.

Answer: average length = 3.576 bits/symbol, entropy = 3.542 bits/symbol, transmission efficiency η ≈ 99.05%.

Codeword for the received message "Engineer Ko Betha Ke Ke"

Each character (including the 4 spaces) is replaced by its code from the table above:

PartCode
engineer000 1010 01110 1100 1010 000 000 1001
space010
ko1011 01100
space010
betha01111 000 1000 111 001
space010
ke1011 000
space010
ke1011 000

Full codeword (83 bits for 23 characters):

000 1010 01110 1100 1010 000
000 1001 010 1011 01100 010
01111 000 1000 111 001 010
1011 000 010 1011 000

The Huffman code is a prefix code, so the receiver can decode this bit stream without separators.

✓ Answer checked by Claude Opus 5.5 (high effort)

All Communication Systems chapter 6 questions →