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

Ternary Huffman. Trimedia Disks Inc. has developed “ternary” hard disks. Each cell on a disk can now store values 0,1, or 2(instead of just 0 or 1). To take advantage of this new technology, provide a modified Huffman algorithm for compressing sequences of characters from an alphabet of size n, where the characters occur with known frequencies f1, f2,...., fn. Your algorithm should encode each character with a variable-length codeword over the values 0,1,2, such that no codeword is a prefix of another codeword and so as to obtain the maximum possible compression. Prove that your algorithm is correct

Short Answer

Expert verified

The Huffman method for compressing sequences of letters from such a vocabulary with n elements, where even the words appear with known frequency f1, f2,....fn, to take use of this new technology.

Step by step solution

01

Ternary Huffman encoding algorithm

Any ternary tree is the one where the nodes are odd in number. In other words, each node has either 0 or 3 children.

• The left child is labelled " 0," the middle child is labelled " 1," and the right child is labelled " 2."

• Make a list of all potential symbols and their frequencies before building the codes for the ternary Huffman tree.

• Identify the three symbols with the lowest frequency.

Achieved By replacing them with a single set that includes all three symbols and has a frequency that is the sum of their respective frequencies.

• Keep going until you get a list with only one member.

02

Encapsulated Proof

Check to see if number the symbols is odd at first. If that's the case, then encapsulate the symbol to create the whole ternary tree.

• Add a symbol with frequency 0 if necessary, to make the number of symbols odd.

• To build the whole optimum tree, just use the binary case with the left child as " 0 ," the middle child as " 1," and the right child as " 2 " with the lowest frequency for each step to form the single node.

The number of nodes is thus reduced by two. If the symbol stays strange, the procedure continues.

Expect the number all elements is odd and that the tree with non-leaf node " u " is the best. It doesn't have three leaves, in other words (child nodes). Then, assuming that there is really no loss in generality, consider all children from node " u" to be leaves, and the " u" node to contain the two children.

• We may improve the code by deleting the children of node " u " resulting in a full ternary tree.

• So, this whole ternary tree is built by connecting the three nodes to a current leaf, and it must have an odd number of nodes (child).

• It is possible to start it from the root node.

03

Conclusion 

The number of sensor nodes increased accordingly for each phase. As little more than a result, every Ternary Huffman compression technique has been updated and is valid.

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

Consider an undirected graph G=(V,E)with nonnegative edge weights role="math" localid="1658915178951" we0. Suppose that you have computed a minimum spanning tree of G, and that you have also computed shortest paths to all nodes from a particular node role="math" localid="1658915296891" sV. Now suppose each edge weight is increased by 1: the new weights are w0e=we+1.

(a) Does the minimum spanning tree change? Give an example where it changes or prove it cannot change.

(b) Do the shortest paths change? Give an example where they change or prove they cannot change.

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

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

Graphs with prescribed degree sequences. Given a list of n positive integers d1,d2,,dn, we want to efficiently determine whether there exists an undirected graphG=(V,E) whose nodes have degrees preciselyd1,d2,,dn . That is, if V={v1,,vn}, then the degree of vi should be exactly di. We call (d1,,dn) the degree sequence of G. This graph G should not contain self-loops (edges with both endpoints equal to the same node) or multiple edges between the same pair of nodes.

(a) Give an example of d1,d2,d3,d4 where all the di3 and d1+d2+d3+d4 is even, but for which no graph with degree sequence(d1,d2,d3,d4) exists.

(b) Suppose that d1d2d3dn and that there exists a graph G=(V,E) with degree sequence (d1,,dn). We want to show that there must exist a graph that has this degree sequence and where in addition the neighbors of v1 are v2,v3,,vdi+1 . The idea is to gradually transform G into a graph with the desired additional property.

i. Suppose the neighbors ofv1 in Gare not v2,v3,,vdi+1. Show that there exists i<jn and uV and such that {v1,vi},{u,vj}Eand {v1,vj},{u,vi}E

ii. Specify the changes you would make to G to obtain a new graph G'=(V,E') with the same degree sequence as G and where (v1,vi)E'.

iii. Now show that there must be a graph with the given degree sequence but in which v1 has neighbors v2,v3,,vdi+1.

c) Using the result from part (b), describe an algorithm that on input d1,,dn (not necessarily sorted) decides whether there exists a graph with this degree sequence. Your algorithm should run in time polynomial in n and in m=i=1ndi .

The basic intuition behind Huffman’s algorithm, that frequent blocks should have short encodings and infrequent blocks should have long encodings, is also at work in English, where typical words like I, you, is, and, to, from, and so on are short, and rarely used words like velociraptor are longer.

However, words like fire!, help!, and run! are short not because they are frequent, but perhaps because time is precious in situations where they are used.

To make things theoretical, suppose we have a file composed of m different words, with frequencies f1,...,fm. Suppose also that for the ithword, the cost per bit of encoding is ci. Thus, if we find a prefix-free code where the ithword has a codeword of length Ii, then the total cost of the encoding will be localid="1659078764835" fi·ci·li.

Show how to modify Huffman’s algorithm to find the prefix-free encoding of minimum total cost.

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