You are on page 1of 3

ELEC1010 Homework 4[20] Deadline: 10pm on 20 Nov (Fri)

Please submit ONE soft copy (pdf only) of your assignment to Canvas
(Assignments) before the deadline. NO LATE Submission! (Zero mark!)

1. [14] From the encoding table as shown below:

Symbol Frequency Codeword


A 50 0
B 40 100
C 30 101
D 20 1100
E 10 1101
F 5 1110
G 2 1111
Table 1

a) [3.5] Build the prefix tree according to the Table 1 above.


b) [3.5] Use Huffman code to assign new codewords to the symbols (A-G)
above. Follow the convention that the group/symbol with higher probability
is assigned a ‘0’ and that with lower probability is assigned a ‘1’. List out
all the codewords in Table 2.

Symbol Frequency Codeword


(Huffman)
A 50
B 40
C 30
D 20
E 10
F 5
G 2
Table 2
c) [2] What is the average codeword length of the original coding (Table 1)?
d) [2] What is the average codeword length by using Huffman code (Table 2)?
e) [2] What is the minimum average number of bits needed to encode each
symbol?
f) [1] Using a fixed-length code, what will be the minimum average number
of bits needed to encode each symbol?

1 of 3
Solution:
a)

b) [3.5 marks]
Symbol Frequency Codeword
(Huffman)
A 50 00
B 40 01
C 30 11
D 20 100
E 10 1010
F 5 10110
G 2 10111

c) 2.6 bit/symbol
d) 2.389 bit/symbol
e) 2.355 bit/symbol
f) 3 bits/symbol

2. [6] Assume a two dimensional parity check code with odd parity is used. We add a
parity bit for each row and for each column as shown in the table below. The
resulting codeword is [D1 D2 D3 D4…D9 P1 P2 P3…P6].
A single-bit error can be corrected using this channel code.

D1 D2 D3 P1
D4 D5 D6 P2
D7 D8 D9 P3
P4 P5 P6 -

For each received codeword, please indicate: [2 marks each]


2 of 3
 Correction: a single bit error occurs (give the position of the bit that
needs correcting e.g. D5)
 No error!
 Cannot correct, multiple errors.

a) [1 1 1 1 1 0 0 1 1 0 0 1 0 0 1]
Correction: a single bit error occurs (D4)

b) [0 0 1 0 1 1 0 1 1 0 1 0 0 0 1]
Cannot correct, multiple errors

c) [1 1 0 1 0 0 0 0 1 0 0 0 0 0 0]
A single bit error (D1)

3 of 3

You might also like