Professional Documents
Culture Documents
Activity [2.2]
• What message has the following ASCII coding?
• 100111110010110111111
========================================================
Activity [2.6]
What is the lowest achievable number of bits per symbol using fixed-length codes for the
following sources?
a) The 26 letters of the alphabet plus a space symbol (27 different source symbols).
b) The result of a sports match, reporting three possibilities: win, lose, and draw.
d) The report of a remote weather station that returns one of four different visibility
b) 3 different possibilities of a sports match = log2 (3) = 1.58 ≈ 2 bit per symbol
1.7 less than 2 bits required for the fixed-length code this code is more efficient
========================================================
Activity [2.2]
A space mission to Mars is recording data about the planet’s surface, and sending the
data back to scientists on Earth for analysis. The experimental data consists of
measurements, given to the nearest centimeter, of how far a probe is able to penetrate
the surface. Scientists have predicted that the surface of the region under test will be
similar to a certain region on Earth, for which they already have penetration data. This
data is given in Table 2.10, where the first column gives the penetration depth (to the
nearest centimeter) and the second column gives the relative frequency of this outcome.
The communications link has a low data rate, so a very efficient coding must be used for
the transmission. A Huffman code is therefore used, based on the data in Table 2.10.
a. Using a fixed-length code, how many bits would be needed for each code word?
b. Work out a Huffman code to find a possible set of code words for the different
penetration depths.
c. What is the average code word length using the Huffman code?
d. Use either your own spreadsheet or the online entropy calculator to determine the
entropy of this source.
e. Calculate the efficiency of:
i. The fixed-length code
ii. The Huffman code.
b)
Symbol لما نرسم نبدأ أوال بترتيب االحتماالت من االكبر لالصغر وليس
ثانيا نجمع اصغر االحتماالت مع بعض ونرتب القيم من االكبر لالصغر الى نهاية الرسمة
عند جمع احتمالين مع بعض1 او0 نكتب
0 واالحتمال االكبر ياخد1 االحتمال االصغر ياخد
0
0.39 0.39 0.39 0.61 1
0.39 0
2
0.18 0.19 0 0.24 1
0.18
3
0.12 0
0.12 0.18 1
4 1
0.07
0.06 0
5
1
0.01
نكتب المعادلة ونعمل جدولAverage code word لما يطلب
c) Average code word length
𝑛
𝑙 ҧ = 𝑙𝑖 𝑝𝑖
𝑖=1
e)
i. Efficiency of fixed-length code = Entropy / fixed-length code = 2.146 / 3 = 0.715 ≈ 72%
ii. Efficiency of Huffman code = Entropy / Huffman code = 2.146 / 2.24 = 0.958 ≈ 96%
C النه بالسؤال فقرةAverage code word length هي نفس قيمةHuffman code قيمة
Huffman code باستخدامAverage code word طلب
Activity [2.13]
A children’s multimedia package contains a simple application for creating music, based
on a keyboard with seven notes: the notes A, B, C, D, E, F, and G
a. How many bits are needed to represent a note of the music using a fixed-length code?
b. The developers of the software carry out some testing with children, and find that the
children click on the keys towards the center of the keyboard much more often than the
keys at each end. In a test of 1000 mouse clicks, the number of times each key was clicked
is as shown in Table 2.11. Calculate the probability of each note being used, based on
these numbers.
c. Derive a Huffman code to represent the notes and calculate the average length of the code
words.
d. Use either your own spreadsheet or the online entropy calculator to determine the
entropy of this source.
e. Calculate the efficiency of:
a. The fixed-length code
b. The Huffman code.
b)
D
0.21
0.21 0.23 0.36 0.41 0.59
0 1
C 0.20 0.21
0.20 0.23 0.36 0 0.41
1
B 0.20
0.19 0.21 0.23
0 1
0.19
0.19 0
E
0.17 0.20 1
0.17 0.17 1
F
0.16 0
0.16
G
0.07 1
0.04 0
A
0.03 1
𝑙 ҧ = 𝑙𝑖 𝑝𝑖
𝐢=𝟏
𝑯 = − 𝒑𝒊 𝒍𝒐𝒈𝟐 ൫𝒑𝒊 ൯
𝒊=𝟏
e)
i. Efficiency of fixed-length code = Entropy / fixed-length code = 2.588 / 3 = 0.863 ≈ 86%
ii. Efficiency of Huffman code = Entropy / Huffman code = 2.588 / 2.66 = 0.973 ≈ 97%
Activity [2.16]
a. Encode the following data using the run-length encoding described above:
E B B B B B B B B A A A A G G G G G G G C C B B B F G.
b. Decode the following sequence, which has been encoded using the same run-length
encoding:
E 4 C 1 D 1 A 1 C 6 B 6 A 2.
a. E 1 B 8 A 4 G 7 C 2 B 3 F 1 G 1
b. E E E E C D A C C C C C C B B B B B B A A
Activity [2.20]
Starting with an initialized coding table, follow through the LZW algorithm step by step and
complete Table 2.18 in order to encode the following sequence:
BACCABACBACBAC
Input data
P Q Code output New coding table entry
code Data
بناء على الجدول االول هنجيب الكود للحرف المكتوب في عمود Pونكتبه في Code output
ناخد الكود الجديد من العمود Pو Qونعطي لهم كود جديد يبدا من 256
لو اتكرر نفس الكود من العمودين Pو Qننزل للصف اللي بعده ونكتبه في عمود Pونشوف الحرف الموجود في Qمع العمود
Pلو م اتكرر نعطي كود متسلسل بناء ع اخر ترقيم لالكواد الجديدة