The Huffman coding tree function buildHuff of Figure 5.29 manipulates a sorted list. This could result in
Question:
The Huffman coding tree function buildHuff of Figure 5.29 manipulates a sorted list. This could result in a (Θn2) algorithm, because placing an intermediate Huffman tree on the list could take Θ(n) time. Revise this algorithm to use a priority queue based on a min-heap instead of a list.
In Figure 5.29
Transcribed Image Text:
// Build a Huffman tree from list hufflist static HuffTree buildTree (List hufflist) { HuffTree tmp1, tmp2, tmp3; LettFreq tmpnode; } for (hufflist.moveToPos (1); hufflist.length() > 1; hufflist.moveToPos (1)) { } // While at least two items left hufflist.moveToStart (); tmpl= hufflist.remove(); tmp2 = hufflist.remove(); tmpnode = new LettFreq (tmpl.weight () + tmp2.weight ()); tmp3 = new HuffTree (tmpnode, tmp1, tmp2); // return to the list in sorted order for (hufflist.moveToStart (); hufflist.currPos () < hufflist.length(); hufflist.next()) if (tmp3.weight () = hufflist.length()) hufflist.append (tmp3); // This is heaviest value hufflist.moveToStart (); // This is only tree on list return hufflist.remove(); // Return the tree.
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Answer rating: 50% (6 reviews)
The provided algorithm in the image is for constructing a Huffman tree using a sorted list As mentioned in the question this could result in an ineffi...View the full answer
Answered By
Zubair Abdulla
.I am a 23 year experienced Professor of Chemistry with PhD in Chemical Technology with specialisation in Technology of Pharmaceuticals and Fine chemicals from Institute of Chemical Technology, Mumbai. I worked in drugs manufacturing industry for several years. Later, out of my passion for teaching and research, I shifted to academics teaching MSc and BSc organic chemistry in a college. For the last five years, I am teaching students online quite successfully
My interactive method of teaching chemistry is well appreciated by students both in India and abroad.
My industrial experience in drug manufacturing could make the students understand the topics from a practical point of view.
Dr. Zubair M A
0.00
0 Reviews
10+ Question Solved
Related Book For
Practical Introduction To Data Structures And Algorithm Analysis Java Edition
ISBN: 9780136609117
1st Edition
Authors: Clifford A. Shaffer
Question Posted:
Students also viewed these Computer science questions
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
Huffman coding animation) Write a program that enables the user to enter text and displays the Huffman coding tree based on the text, as shown in Figure 25.23a. Display the weight of the subtree...
-
Write a program that enables the user to enter text and displays the Huffman coding tree based on the text, as shown in Figure 25.25a. Display the weight of the subtree inside the subtree?s root...
-
Read the case study about Joy Jowie Inc and write a detailed paper about it
-
A certain industrial process requires a steady stream of saturated vapor water at 200 kPa at a rate of 2 kg/s. There are two alternatives for supplying this steam from ambient liquid water at...
-
Carina buys two goods, food F and clothing C, with the utility function U = FC + F. Her marginal utility of food is MUF = C + 1 and her marginal utility of clothing is MUC = F. She has an income of...
-
Think about an individual you know and respect at school or at work. What technical, cognitive, and relational competencies does the person have that you admire? Why do you admire these competencies?...
-
This exercise is a continuation of E5-13. Proud Corporation acquired 80 percent of Stergis Companys voting stock on January 1, 20X3, at underlying book value. The fair value of the noncontrolling...
-
Comparative data on three companies in the same service industry are given below: Required: 2. Fill in the missing information. (Round the "Turnover" and "ROI" answers to 2 decimal places.) Company C...
-
Complete the implementation of the Huffman coding tree, building on the code presented in Section 5.6. Include a function to compute and store in a table the codes for each letter, and functions to...
-
Implement a priority queue class based on the max-heap class implementation of Figure 5.19. The following methods should be supported for manipulating the priority queue: void enqueue(int ObjectID,...
-
22 Public Issues versus Private Placements Which of the following are characteristics of public issues, and which are characteristics of private placements? (a) Stock exchange registration required...
-
Let f(x) = x+ 3, x20. The inverse of f is Of 1(x)=x - 3 (f (x) = -x-3 f-(x) = x - 3 Of 1(x) = 3 - x
-
Read the articles and please help me to write the whole assignment perfectly including the citations and references (APA Format). Pleaase choose the country and perspective of a particular industry....
-
A light, inextensible cord passes over a frictionless pulley as shown in figure below. One end of the rope is attached to a block, and a force P is applied to the other end. Block A weighs 600 lb and...
-
BASICOT POST DO NOT ASSIST DO NOT POST DO NOT ASSIST DO NOT POST DO NOT ASSIST For filming a physics demonstration about oscillation, an educational video crew attaches a large spring to a very small...
-
Day Mail Order Co. applied the high-low method of cost estimation to customer order data for the first 4 months of the year. What is the estimated variable order-filling cost component per order...
-
An adiabatic heat exchanger is to cool ethylene glycol (cp = 2.56 kJ/kg C) flowing at a rate of 2 kg/s from 80 to 40C by water (cp = 4.18 kJ/kg C) that enters at 20C and leaves at 55C. Determine...
-
The Cholesterol Level data sets give cholesterol levels of heart attack patients. Cholesterol measures are taken 2, 4, and 14 days aft er a patient has suffered a heart attack. Is there a significant...
-
Suppose we modify the deterministic version of the quick-sort algorithm so that, instead of selecting the last element in an n-element sequence as the pivot, we choose the element at index n/2. What...
-
Suppose we are given two n-element sorted sequences A and B each with distinct elements, but potentially some elements that are in both sequences. Describe an O(n)-time method for computing a...
-
Is our linked-list-based implementation of merge-sort (Code Fragment 12.3) stable? Explain why or why not. /** Merge contents of sorted queues S1 and S2 into empty queue S. */ public static void...
-
5. The current spot exchange rate is 0.95/$ and the three-month forward rate is 0.91/$. Based on your analysis of the exchange rate, you are pretty confident that the spot exchange rate will be...
-
Ray Company provided the following excerpts from its Production Department's flexible budget performance report. Required: Complete the Production Department's Flexible Budget Performance Report....
-
Problem 1 5 - 5 ( Algo ) Lessee; operating lease; advance payment; leasehold improvement [ L 0 1 5 - 4 ] On January 1 , 2 0 2 4 , Winn Heat Transfer leased office space under a three - year operating...
Study smarter with the SolutionInn App