1 Kingdom of Saudi Arabia
Ministry of Education Umm AlQura University
Adam University College, female branch Computer Science Department
ةيدوعسلا ةيبرعلا ةكلمملا ميلعتلا ةرازو ةعماج ىرقلا مأ تابلاطلا رطش ،مضأب ةيعماجلا ةيلكلا
يللآا بساحلا مولع مسق
First Semester of 2017-2018 Academic Year
Multimedia Systems Course, 6803316-3 Worksheet Two
Data Compression
Names University IDs
Date:
Wednesday, 20/12/2017
[ / 2 ] Question One:
0.5 MarkChoose the best answer:
*By using Run-Length-Coding Algorithm, "aaaabbcccccaaaaaabaaaaaaaabbccc", this group of characters can be represented in only ……….. instead of 31 characters.
a) 12 characters b) 16 characters c) 25 characters d) 35 characters 4a2b5c6a1b8a2b3c
True/ False, with the correction if the statement is false:
*For image compression in multimedia applications, where a higher compression ratio is required, lossless methods are usually adopted. ( False )
For higher compression ratio in image compression, lossy methods are used.
2
Question Two:
0.5 Mark-Compress the word “TEACHER” using Shannon-Fanno Algorithm.
-Then find the count for each symbol, the code and the average number of bits used.
The Answer:
1.
ETACHR 2.
7
0 1
E:(2) TACHR:(5)
0 1
T:(1) ACHR:(4)
0 1
A:(1) CHR:(3)
0 1
C:(1) HR:(2)
0 1
H:(1) R:(1)
Symbol Count Code # of bits used
E 2 0 2
T 1 10 2
A 1 110 3
C 1 1110 4
H 1 11110 5
R 1 11111 5
Sum = 21 Bits The Average Number of Bits Used is: 𝟐𝟏
𝟕 = 𝟑
3
Question Three:
0.5 Mark-Compress the same word “TEACHER” used in question two, using Huffman Algorithm.
-Then find the count for each symbol, the code and the average number of bits used.
-Compare the average with Shannon-Fanno Algorithm?
The Answer:
1.The List:
After Initliaztion: ETACHR After First Interation: ETACP1 After Second Interation: ETAP2 After Third Interation: ETP3 After Fourth Interation: EP4 After Fifth Interation: P5 2.The Tree:
P5:(7) 0 1
P4:(5) E:(2) 0 1
T:(1) P3:(4)
0 1 P2:(3) A:(1) 0 1
P1:(2) C:(1) 0 1
H:(1) R:(1)
3.
Symbol Count Code # of bits used
E 2 0 2
T 1 01 2
A 1 011 3
C 1 0111 4
H 1 01111 5
R 1 11111 5
Sum = 21 Bits The Average Number of Bits Used is: 𝟐𝟏
𝟕 = 𝟑 Both Algorithms have the same average.
4
Question Four:
0.5 Mark-Compress the string “ummalqura” using the Dictionary Based Coding Algorithm.
-Decompress the string to get back the original string.
The Answer:
1.Compression(Encoding):
The characterstream: ummalqura
Index Dictionary
1 u
2 m
3 a
4 l
5 q
6 r
7 um
8 mm
9 ma
10 al
11 lq
12 qu
13 ur
14 ra
P = r C = a P + C = ra The codestream:
1 2 2 3 4 5 1 6 3
2.Decompression(Decoding):
The codestream:
1 2 2 3 4 5 1 6 3
Index Dictionary
1 u
2 m
3 a
4 l
5 q
6 r
7 um
8 mm
9 ma
10 al
11 lq
12 qu
13 ur
14 ra
pW= 6 string.pW = r cW= 3 string.cW = a
P = r C = a P + C = ra The characterstream:
umalqura
5
Good Luck my Great Students 😉 T.Mariah Sami Ahmed Khayat
Teacher Assistant @ Adam University College [email protected]