Question 2(25p) Write a method that will create a Huffman tree considering below; HuffmanNode class has...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Question 2(25p) Write a method that will create a Huffman tree considering below; HuffmanNode class has the public class variables; float frequency, String symbol, HuffmanNode left, right, next. The constructor takes frequency and symbol values. Linked ListHuffman class has private class variable; HuffmanNode head and the following methods implemented in this class for you to use in case you need them; Public void insertSorted (HuffmandNode newONe) // insert a given node into the linked list in an ascending order based on their frequencies. Public HuffmanNode delete() //remove the first element(with the lowest frequency) from the linked list and returns it. Public int count() // will count the number of elements in the linked list. Assume that for each symbol in your text, the frequency was found, HuffmanNode was created and inserted into a linked list using the method mentioned above. The method that you are going to write will be in the HuffmanTree class. This class has a variable root in the type of HuffmanNode. Public void createHuffman Tree(Linked ListHuffman list){//list is the sorted one based on frequencies } Question 2(25p) Write a method that will create a Huffman tree considering below; HuffmanNode class has the public class variables; float frequency, String symbol, HuffmanNode left, right, next. The constructor takes frequency and symbol values. Linked ListHuffman class has private class variable; HuffmanNode head and the following methods implemented in this class for you to use in case you need them; Public void insertSorted (HuffmandNode newONe) // insert a given node into the linked list in an ascending order based on their frequencies. Public HuffmanNode delete() //remove the first element(with the lowest frequency) from the linked list and returns it. Public int count() // will count the number of elements in the linked list. Assume that for each symbol in your text, the frequency was found, HuffmanNode was created and inserted into a linked list using the method mentioned above. The method that you are going to write will be in the HuffmanTree class. This class has a variable root in the type of HuffmanNode. Public void createHuffman Tree(Linked ListHuffman list){//list is the sorted one based on frequencies }
Expert Answer:
Answer rating: 100% (QA)
To create a Huffman Tree we need to follow a specific algorithm that will construct the tree from a ... View the full answer
Related Book For
Data Structures and Algorithm Analysis in Java
ISBN: 978-0132576277
3rd edition
Authors: Mark A. Weiss
Posted Date:
Students also viewed these programming questions
-
Required Information [The following information applies to the questions displayed below.] The first production department of Stone Incorporated reports the following for April. Direct Materials...
-
This assignment reviews object-oriented programming concepts such as classes, methods, constructors, accessor methods, and access modifiers. It makes use of an array of objects as a class data...
-
Why do joints tend to be evenly spaced rather than clustered?
-
The Economist observed, "In Argentina, many loans were taken out in dollars: this had catastrophic consequences for borrowers once the peg collapsed." What does the article mean when it says that...
-
Roberts Inc. has the following loans at the end of Year3: $200,000 note payable to First National Bank (FNB). The bank requires monthly payments of interest of $1,000 at the end of each month. (No...
-
Refer to the information from QS 21-18. Compute the variable overhead spending variance and the variable overhead efficiency variance and classify each as favorable or unfavorable. Data From QS 21-18...
-
Presented below are data on three promissory notes. Determine the missingamounts. Date of Note Total Maturity Annual Interest Rate Principal Terms 60 days 30 days 6 months Date Interest (a) April 1...
-
Define the relational model? What does the relational model consist of? What are the 4 relational models?Discuss
-
The comparative statements of Wahlberg Company are presented here. All sales were on account. Net cash provided by operating activities for 2017 was $220,000. Capital expenditures were $136,000, and...
-
Use the following information and answer the questions that follow. C = 1860 + 0,91Y I = 1200 G = 1550 X = 890 M = 670 t = 0,36 1.1.1 Calculate and write down the Total Expenditure function of this...
-
Barnes & Noble Inc. reported the following financial information for its last fiscal year (all numbers in thousands): Revenues $6,839,005 Inventory $1,410,769 A/P $1,374,434 A/R $149,369 AAI 105.21...
-
A company operates an EOQ policy. It has annual demand of 120,000 units and a fixed order cost of 50. Its EOQ level is 5,000 units. Assuming no safety stock, zero lead time, and all assumptions of...
-
Suppose you want to buy a house that cost $100, 000.00 The bank requires a 5.0% down payment and will charge 10.80% interest compounded monthly. Suppose you put down the least amount that you could...
-
A grade 12 physics student on a homemade hovercraft travels with an initial velocity of 1.45 m/s east undergoes an average acceleration of 2.10 m/s^2 south for 2.5 seconds. What is the final velocity...
-
calculate hoW many Coupon bond must be Issued? calculate hoW many Zero Coupon bond must be Issued? Capital to be raised Number of years to maturity: Coupon bond YTM: Annual coupon rate: Coupon per...
-
A factory is in a position to manufacture three products P. Q and R. Raw material required for each unit of P, Q and R is 1kg, 2kg and 2.5kg respectively and costs N$2. Total raw material is 350kg....
-
Using Apple, demonstrate how the differentiation strategy can be well implemented.
-
Extend the reconstruction algorithm to find all homometric point sets given a distance set.
-
Othello played on a 6-by-6 board is a forced win for black. Prove this by writing a program. What is the final score if play on both sides is optimal?
-
Write a recursive method that takes a reference to the root node of a tree T and returns a reference to the root node of the tree that results from removing all leaves from T.
-
What are the functions of activator proteins and repressor proteins in transcription? Explain how these proteins work at the molecular level.
-
The gene that encodes the enzyme called tyrosine hydroxylase is known to be activated by the CREB protein. Tyrosine hydroxylase is expressed in nerve cells and is involved in the synthesis of...
-
The binding of small effector molecules, protein-protein interactions, and covalent modifications are three common ways to modulate the activities of transcription factors. Which of these three...
Study smarter with the SolutionInn App