You are on page 1of 4

Dwi Putri Wahyuningsih

2019390004

HW-Tunstall Coding

Y = {A, B, C, D}

P = (0.1, 0.2, 0.3, 0.4)

Create a codebook for 4 bit-Tunstall code.

Initial Code

A 0.1
B 0.2
C 0.3
D 0.4
D has the bigger value, so we remove it from table
First Iteration

A 0.1
B 0.2
C 0.3
AD 0.04
BD 0.08
CD 0.12
DD 0.16
C has the bigger value, so we remove it from table

Second Iteration

A 0.1
B 0.2
AC 0.03
AD 0.04
BC 0.06
BD 0.08
CC 0.09
CD 0.12
DC 0.12
DD 0.16
B has the bigger value, so we remove it from table
Third Iteration

A 0.1
AB 0.02
AC 0.03
AD 0.04
BB 0.04
BC 0.06
BD 0.08
CB 0.06
CC 0.09
CD 0.12
DB 0.08
DC 0.12
DD 0.16
DD has the bigger value, so we remove it from table
Fourth Iteration (Codebook)

A 0000
AB 0001
AC 0010
AD 0011
BB 0100
BC 0101
BD 0110
CC 0111
CD 1000
DB 1001
DC 1010
DD 1011
ADD 1100
BDD 1101
CDD 1110
DDD 1111

You might also like