Warning: foreach() argument must be of type array|object, bool given in /var/www/html/web/app/themes/studypress-core-theme/template-parts/header/mobile-offcanvas.php on line 20

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

Show that for any integer n that is a power of 2 , there is an instance of the set cover problem (Section 5.4) with the following properties:

  1. There are n elements in the base set.
  2. The optimal cover uses just two sets.
  3. The greedy algorithm picks at least log n sets.

Thus the approximation ratio we derived in the chapter is tight.

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 1โ‰คiโ‰คn, 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?

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.

We use Huffman's algorithm to obtain an encoding of alphabet {a,b,c}with frequencies fa,fb,fc. In each of the following cases, either give an example of frequencies (fa,fb,fc)that would yield the specified code, or explain why the code cannot possibly be obtained (no matter what the frequencies are).

(a) Code:{0,10,11}

(b) Code:{0,1,00}

(c) Code:{10,01,00}

Let G=(V,E) be an undirected graph. Prove that if all its edge weights are distinct, then it has a unique minimum spanning tree

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