Under a Huffman encoding of symbols with frequenciesf1,f2,.....,fn , what is the longest a codeword could possibly be? Give an example set of frequencies that would produce this case.

Short Answer

Expert verified

The longest codeword possible for symbols with frequencies f1,f2,.....,fnisn-1 .

Step by step solution

01

Prefix-free encoding

It is not possible to have a codeword be the prefix of another. If so, it will create ambiguity. Hence, Huffman codewords are found using prefix-free encoding. Prefix-free encoding is done by creating a full binary tree.

02

Generation of Huffman codewords

A Huffman encoding of n symbols has n leaves in the full binary tree. Each symbol will have codeword equal to the path from the root to leaf node. So, the frequency which is on the lowest level of tree has the longest codeword.

For example: Consider three symbols (n=3) a,b,cwith frequencies 14,14,12respectively. The full binary tree representation is:

Here, the codewords for a,b,care 00,01,1respectively. a and b have the longest codeword of length 2 . So, a Huffman encoding of 3 symbols has longest codeword of length 2.

03

Calculation of the longest codeword possible

Maximum height of a full binary tree with n nodes isn-1. The length of the codeword of symbols is the height of full binary tree. Therefore, longest codeword possible for a Huffman encoding of symbols is n-1.

Hence, a Huffman encoding of n symbols have a codeword with maximum lengthn-1 .

Unlock Step-by-Step Solutions & Ace Your Exams!

  • Full Textbook Solutions

    Get detailed explanations and key concepts

  • Unlimited Al creation

    Al flashcards, explanations, exams and more...

  • Ads-free access

    To over 500 millions flashcards

  • Money-back guarantee

    We refund you if you fail your exam.

Over 30 million students worldwide already upgrade their learning with Vaia!

One App. One Place for Learning.

All the tools & learning materials you need for study success - in one app.

Get started for free

Most popular questions from this chapter

Ternary A server has customers waiting to be served. The service time required by eachcustomer is known in advance: it is ciminutes for customer i. So if, for example, the customers are served in order of increasing i , then the ithcustomer has to wait Pij=1tjminutes. We wish to minimize the total waiting time.

T=Xni=1(time spent waiting by customer ).

Give an efficient algorithm for computing the optimal order in which to process the customers.

Consider the following graph.

(a) What is the cost of its minimum spanning tree?

(b) How many minimum spanning trees does it have?

(c) Suppose Kruskal’s algorithm is run on this graph. In what order are the edges added to the MST? For each edge in this sequence, give a cut that justifies its addition.

Entropy: Consider a distribution overnpossible outcomes, with probabilities p1,p2,K,pn.

a. Just for this part of the problem, assume that each piis a power of 2 (that is, of the form 1/2k). Suppose a long sequence of msamples is drawn from the distribution and that for all 1in, the ithoutcome occurs exactly times in the sequence. Show that if Huffman encoding is applied to this sequence, the resulting encoding will have length

i-1nmpilog1pi

b. Now consider arbitrary distributions-that is, the probabilities pi are noy restricted to powers of 2. The most commonly used measure of the amount of randomness in the distribution is the entropy.

i-1nmpilog1pi

For what distribution (over outcomes) is the entropy the largest possible? The smallest possible?

The following table gives the frequencies of the letters of the English language (including the blank for separating words) in a particular corpus.

blank

18.3%

r

4.8%

y

1.6%

e

10.2%

d

3.5%

p

1.6%

t

7.7%

l

3.4%

b

1.3%

a

6.8%

c

2.6%

v

0.9%

o

5.9%

u

2.4%

k

0.6%

i

5.8%

m

2.1%

j

0.2%

n

5.5%

w

1.9%

x

0.2%

s

5.1%

f

1.8%

q

0.1%

h

4.9%

g

1.7%

z

0.1%

  1. What is the optimum Huffman encoding of this alphabet?
  2. What is the expected number of bits per letter?
  3. Suppose now that we calculate the entropy of these frequencies

H=t=026ptlog1pt

(see the box in page 143). Would you expect it to be larger or smaller than your answer above? Explain.

d. Do you think that this is the limit of how much English text can be compressed? What features of the English language, besides letters and their frequencies, should a better compression scheme take into account?

Show how to find the maximum spanning tree of a graph, that is , the spanning tree of largest total weight.

See all solutions

Recommended explanations on Computer Science Textbooks

View all explanations

What do you think about this solution?

We value your feedback to improve our textbook solutions.

Study anywhere. Anytime. Across all devices.

Sign-up for free