A text is made up of the characters A, B, C, D, E each occurring with the probability 0.08, 0.40, 0.25, 0.15 and 0.12 respectively. The optimal coding technique will have the average length of :
Pick an option to check yourself, or open the answer below.
Show answer & explanation
Correct answer: D. 2.15
Explanation
Merge 0.08 + 0.12 = 0.20, then 0.15 + 0.20 = 0.35, then 0.25 + 0.35 = 0.60, then 0.40 + 0.60. Code lengths: B 1, C 2, D 3, A 4, E 4. Average = 0.40 + 0.50 + 0.45 + 0.32 + 0.48 = 2.15.
More Data Structures and Algorithms questions
- A binary search tree in which every non-leaf node has non-empty left and right subtrees is called a strictly binary tree. Such a tree with…
- Match the following with respect to algorithm paradigms :
- The maximum number of comparisons needed to sort 9 items using radix sort is (assume each item is 5 digit octal number) :
- A 5-ary tree is tree in which every internal node has exactly 5 children. The number of left nodes in such a tree with 8 internal nodes wil…
- Consider a Boolean function of ‘n’ variables. The order of an algorithm that determines whether the Boolean function produces a output 1 is…
- Consider a hash table of size seven, with starting index zero, and a hash function (7x+3) mod 4. Assuming the hash table is initially empty…