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

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?

Prove the following two properties of the Huffman encoding scheme.

(a) If some character occurs with frequency more than 25, then there is guaranteed to be a codeword of length 1 .

(b) If all characters occur with frequency less than13 , then there is guaranteed to be no codeword of length 1 .

A long string consists of the four characters A,C,G,T ; they appear with frequency 31%,20%,9%and40% respectively. What is the Huffman encoding of these four characters?

A prefix-free encoding of a finite alphabet ฮ“ assigns each symbol in ฮ“ a binary codeword, such that no codeword is a prefix of another codeword. A prefix-free encoding is minimal if it is not possible to arrive at another prefix-free encoding (of the same symbols) by contracting some of the keywords. For instance, the encoding {0,101} is not minimal since the codeword 101 can be contracted to 1 while still maintaining the prefix-free property.

Show that a minimal prefix-free encoding can be represented by a full binary tree in which each leaf corresponds to a unique element of ฮ“, whose codeword is generated by the path from the root to that leaf (interpreting a left branch as 0 and a right branch as 1 ).

Suppose you are given a weighted graph G=(V,E) with a distinguished vertex s and where all edge weights are positive and distinct. Is it possible for a tree of shortest paths from s and a minimum spanning tree in G to not share any edges? If so, give an example. If not, give a reason.

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