Question

In: Computer Science

Q. Given a document with 32 distinct characters, with equal number of occurrences of each, what...

Q. Given a document with 32 distinct characters, with equal number of occurrences of each, what would be the ratio of the length of the Huffman coded document to the original, if each character in the input was coded in 8 bits? Show your analysis.

Solutions

Expert Solution

Given a document with 32 distinct characters, with equal number of occurrences of each

For example ---->

Plain Text = ABCDEFGHIJKLMNOPQRSTUVWXYZ012345

Huffman Coded Text = 11100 01010 00101 00001 10001 10111 00011 10011 01001 00110 10110 00000 01000 10010 11101 10100 01111 00010 01011 11011 11110 00100 11001 00111 01101 10101 10000 11010 11000 01110 11111 01100

If each character in the input was coded in 8 bits then total bits required = 32*8 = 256 bits

Total bits of the Huffman coded document = 32*5 = 160

So ratio of the length of the Huffman coded document to the original = 160/256 = 5/8

or Compression rate: 0.625
Seq.no. Chars ASCII Frequency Huffman ASCII
0 '0' 48 1 10000 00110000
1 '1' 49 1 11010 00110001
2 '2' 50 1 11000 00110010
3 '3' 51 1 01110 00110011
4 '4' 52 1 11111 00110100
5 '5' 53 1 01100 00110101
6 'A' 65 1 11100 01000001
7 'B' 66 1 01010 01000010
8 'C' 67 1 00101 01000011
9 'D' 68 1 00001 01000100
10 'E' 69 1 10001 01000101
11 'F' 70 1 10111 01000110
12 'G' 71 1 00011 01000111
13 'H' 72 1 10011 01001000
14 'I' 73 1 01001 01001001
15 'J' 74 1 00110 01001010
16 'K' 75 1 10110 01001011
17 'L' 76 1 00000 01001100
18 'M' 77 1 01000 01001101
19 'N' 78 1 10010 01001110
20 'O' 79 1 11101 01001111
21 'P' 80 1 10100 01010000
22 'Q' 81 1 01111 01010001
23 'R' 82 1 00010 01010010
24 'S' 83 1 01011 01010011
25 'T' 84 1 11011 01010100
26 'U' 85 1 11110 01010101
27 'V' 86 1 00100 01010110
28 'W' 87 1 11001 01010111
29 'X' 88 1 00111 01011000
30 'Y' 89 1 01101 01011001
31 'Z' 90 1 10101 01011010

Related Solutions

In this program: ================================================================== /* Program to count number of occurrences of a given string in...
In this program: ================================================================== /* Program to count number of occurrences of a given string in original string*/ #include <iostream> #include <cstring> #include <stdio.h> #include <iostream> using namespace std; int main() { const int SIZE = 40; char str[SIZE]; char str1[SIZE]; char searchString[SIZE]; int n; int l1, l2; int count = 0; printf("Enter a sentence: \n"); fgets(str,SIZE,stdin); printf("Enter a search word: \n"); fgets(searchString,SIZE,stdin); if (str1[strlen(str1) - 1] == '\n') { str1[strlen(str1)-1] = '\0'; } if (str[strlen(str) - 1] == '\n')...
What is the quickest way to scan through a document to show you all occurrences of...
What is the quickest way to scan through a document to show you all occurrences of the keywords? A.Use the scroll bar on the right hand side of your internet browser B.Use the change view buttons in the top right hand corner of the document C.Press the Next/Previous button at the top of the document D.Use the Hits bar at the bottom of the document
For the following exercises, find the number of subsets in each given set. A set containing 5 distinct numbers, 4 distinct letters, and 3 distinct symbols
For the following exercises, find the number of subsets in each given set.A set containing 5 distinct numbers, 4 distinct letters, and 3 distinct symbols
The market demand for a particular good in city A is given by Q(A) = 32...
The market demand for a particular good in city A is given by Q(A) = 32 ? 0.5P (for P ? 64). This market is served by a single firm (monopoly) whose marginal cost of production is 4 dollars per unit (so total cost of producing Q units is 4Q). (a) Find the equation for the firm’s marginal revenue function. Draw the demand, marginal cost and marginal revenue curves on one graph. (b) What are the profit-maximizing price and quantity...
The inverse demand function in a market is given by p=32-Q where Q is the aggregate quantity produced.
  The inverse demand function in a market is given by p=32-Q where Q is the aggregate quantity produced. The market has 3 identical firms with marginal and average costs of 8. These firms engage in Cournot competition.   a) How much output does each firm produce? b) What is the equilibrium price in the market? c) How much profit does each firm make? d) Consider a merger between two firms. Assuming that due to efficiency gains from the merger,...
There are 6 numbered balls in a bag. Each ball has a distinct number and the...
There are 6 numbered balls in a bag. Each ball has a distinct number and the numbers are in {1, 2, 3, 4, 5, 6}. Take 3 balls from the bag (without replacement) randomly and read the number on each ball. Let X1 be the maximum number and X2 be the minimum number among the three observed numbers. (a) Find the marginal p.m.f. of X1. (b) Find the marginal p.m.f. of X2. (c) Find the joint p.d.f. of X1 and...
The domestic demand for bicycles is given by Q = 32/0.3 – P/0.3    The foreign supply...
The domestic demand for bicycles is given by Q = 32/0.3 – P/0.3    The foreign supply is given by P = 16 and domestic supply by Q = P/0.4 - 12/0.4 If a 3$ tarriff is added compute the price and quantity in equilibrium with free trade, and again in the presence of the tariff. Show the dead-weight loss Explain costs and benefits of a tariff
Determine the number of DISTINCT colorings of the four faces of a tetrahedron, where each face...
Determine the number of DISTINCT colorings of the four faces of a tetrahedron, where each face is a color from the set { orange, purple, black} - Frobenius Orbit counting
Find the six nonisomorphic trees on 6 vertices, and for each compute the number of distinct...
Find the six nonisomorphic trees on 6 vertices, and for each compute the number of distinct spanning trees in K6 isomorphic to it.
Suppose the market demand is given by: Q=125-25P and that MC is equal to zero. There...
Suppose the market demand is given by: Q=125-25P and that MC is equal to zero. There are no fixed costs. Solve (a)-(d) as a Cournot model. (a). Write down the profit maximization function for each firm. (b). Calculate the FOC’s and find the best response functions (BR1(q2) and BR2(q1)) (c). Describe what a “best response function” is in words. What must be true for best responses at the Nash equilibrium? (d). Calculate the Nash equilibrium (quantities) in this market and...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT