




























Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!





























I (^) used for data compression, typically saving 20%–90%
I (^) used for data compression, typically saving 20%–90%
I (^) Basic idea: represent often encountered characters by shorter (binary) codes
Example I (^) Suppose we have the following data file with total 100 characters: Char. a b c d e f Freq. 45 13 12 16 9 5 3-bit fixed length code 000 001 010 011 100 101 variable length code 0 101 100 111 1101 1100 I (^) Total number of bits required to encode the file: I (^) Fixed-length code: 100 × 3 = 300
Example I (^) Suppose we have the following data file with total 100 characters: Char. a b c d e f Freq. 45 13 12 16 9 5 3-bit fixed length code 000 001 010 011 100 101 variable length code 0 101 100 111 1101 1100 I (^) Total number of bits required to encode the file: I (^) Fixed-length code: 100 × 3 = 300 I (^) Variable-length code: 1 ·45 +3·13 + 3·12 + 3·16 + 4·9 + 4·5 = 225
Prefix(-free) codes:
(^1) a word, letter or number placed before another
Prefix(-free) codes:
(^1) a word, letter or number placed before another
Prefix(-free) codes:
(^1) a word, letter or number placed before another
Prefix(-free) codes:
(^1) a word, letter or number placed before another
Cost and optimality
Let C = alphabet (set of characters), then
Cost and optimality
Let C = alphabet (set of characters), then I (^) A code = a binary tree T
Cost and optimality
Let C = alphabet (set of characters), then I (^) A code = a binary tree T I (^) For each character c ∈ C, define f (c) = frequency of c in the file dT (c) = length of the code for c = number of bits = depth of c’ leave in the tree T
Cost and optimality
Let C = alphabet (set of characters), then I (^) A code = a binary tree T I (^) For each character c ∈ C, define f (c) = frequency of c in the file dT (c) = length of the code for c = number of bits = depth of c’ leave in the tree T Then the number of bits (“cost of the tree/code T ”) required to encode the file B(T ) =
c∈C
f (c) · dT (c),