Construct a huffman code tree

Assignment Help JAVA Programming
Reference no: EM13807082

Review Questions

1. Draw the tree that would be formed by inserting the words in this question into a binary search tree. Use lowercase letters.

2. Show all three traversals of this tree.

3. Show the tree from Question 1 after removing draw, by, and letters in that order.

4. Answer Question 1, but store the words in a heap instead of a binary search tree.

5. Given the following frequency table, construct a Huffman code tree. Show the initial priority queue and all changes in its state as the tree is constructed.

Symbol Frequency
x 34
y 28
w 20
a 10
b 8
c 5

Programming Projects

1. Assume that a class Expressi onTree has a data field that is a BinaryTree. Write an instance method to evaluate an expression stored in a binary tree whose nodes contain

Review Questions

1. Show where the following keys would be placed in a hash table of size 5 using open addressing: 1000, 1002, 1007, 1003. Where would these keys be after rehashing to a table of size 11?

2. Answer Question 1 for a hash table that uses chaining.

3. Write a toString method for class Hashtabl eOpen. This method should display each table element that is not null and is not deleted.

4. Class Hashtabl eChain uses the class Li nkedlis t, which is implemented as a double-linked list. Write the put method using a single linked list to hold elements that hash to the sane index.

5. Write the get method for the class in Question 4.

6. Write the reffove method for the class in Question 4.

7. Write inner class Ent rySet for the class in Question 4 (see Listing. 7.11).

Programming Projects

1. Complete all methods of class HuffmanTree and test them out using a document file and a Java source file on your computer. You can download class Bi tSt ring from the Web site for this textbook.

2. the a HashNap to store the frequency counts for all the words in a large text document. When vnn arc done ilicrdav the contents of this Hachlian Nm create a we view of the

Programming Projects

I. Assume that a class ExpressionTree has a data field that is a BinaryTree. Write an instance method to evaluate an expression stored in a binary tree whose nodes contain either integer values (stored in Integer objects) or operators (stored in Character objects). Your method should implement the following algorithm.

Algorithm to Evaluate an Expression Tree

1. if the root node is an Integer object

2. Return the integer value.

3. else if the root node is a Character object

4. Let leftVal be the value obtained by recursively applying this algorithm to the left subtree.

5. Let rightVal be the value obtained by recursively applying this algorithm to the right subtree.

6. Return the value obtained by applying the operator in the root node to leftVal and rightVal.

Use method readBi naryTree to read the expression tree.

2. Write an application to test the HuffnanTree class. Your application will need to read a text file and build a frequency table for the characters occurring in that file. Once that table is built, create a Huffman code tree and then a string consisting of '0' and '1' digit characters that represents the code string for that file. Read that string back in and re-create the contents of the original file.

3. Solve Programming Project 4 in Chapter 4, 'Queues," using the class Priori tyQueue.

4. Build a generic Huffmaniree.cT> class such that the symbol type T is specified when the tree
is created. Test this class by using it to encode the words in your favorite nursery rhyme.

5. Write clone, size, and height methods for the BinaryTree class.

Programming Projects

1. Complete all methods of class HuffmanTree and test them out using a document file and a Java source file on your computer. You can download class Bi tStri ng from the Web site for this textbook.

2. Use a FleshMap to store the frequency counts for all the words in a large text doctunent. When you are done, display the contents of this HashMap. Next, create a set view of the Map and store its contents in an array. Then sort the array based on key value and display it. Finally, sort the array in decreasing order by frequency and display it.

3. Solve Project 2 using a TreeMap. You can display the words in key sequence without performing a sort.

4. Modify Project 2 to save the line numbers for every occurrence of a word as well as the count.

5. (Based on an example in Brian W. Kernighan and Rob Pike, The Practice of Programming, Addison-Wesley, 1999) We want to generate "random text" in the style of another author. Your first task is to collect a group of prefix strings of two words that occur in a text file and associate them with a list of suffix strings using a Map. For example, the text for Charles Dickens' A Christmas Carol contains the four phrases:

Marley was dead: to begin with. Marley was as dead as a door-nail. Marley was as dead as a door-nail. Marley was dead.

The prefix string "Marley was" would be associated with the ArrayList containing the four suffix strings "dead: ", "as", "as", "dead. ''. You must go through the text and examine each successive pair of two-word strings to see whether that pair is already in the map as a key. If so, add the next word to the ArrayLi st that is the value for that prefix string. For example, in examining the first two sentences shown, you would first add to the entry ("Harley was", ArrayLi st "dead :"). Next you would add the entry ("was dead", ArrayList "as"). Next you would add the entry ("dead as", ArrayList "al, and so on.

Reference no: EM13807082

Questions Cloud

Example inventory list for staff : The warehouse manager asked you to create an example inventory list for his staff. The inventory list is a comprehensive chart that lists all of the company's internal resources: equipment, machines, technology, furniture, office supplies, etc.
Iranian theocracy : Iranian Theocracy
Analyze how coppa and cipa are similar : Analyze how COPPA and CIPA are similar and how they are different, and explain why there is a need for two (2) different acts. Describe what you believe are the most challenging elements of both COPPA and CIPA to implement in order to be compliant
Problems based on concept data is discrete or continuous. : Describe a recent Gallup poll. Be sure to include the results of the poll, how the poll was conducted, and what the results will be used for
Construct a huffman code tree : Draw the tree that would be formed by inserting the words in this question into a binary search tree and construct a Huffman code tree. Show the initial priority queue and all changes in its state as the tree is constructed.
What impact did each book have on your thinking : What impact did each book have on your thinking
Direct the activities of their employees : Communication and motivation are important skills for managers to use to direct the activities of their employees. These tools are used to help connect employees' efforts to company strategies.
What is the probability that the number of fans at any given : In its third year, the Liberty Football League averaged 16,050 fans per game, with a standard deviation of 2,050 fans. According to these data, a. What is the probability that the number of fans at any given game was greater than 20,000?
Discuss what are the three types of casual relationships : Discuss what the three types of "Casual Relationships" are and why they are so important? Discuss "Who is a Moral Person" and why that is important to you, and to society/civilization?

Reviews

Write a Review

JAVA Programming Questions & Answers

  Create a java class named headphones

Create a Java class named HeadPhones to represent a headphone set. The class contains- A private String data field named manufacturer that specifies the name of· A private boolean data field named pluggedIn that specifies if the headphone is plugge..

  Write program to keep track of a hardware stores inventory

Write a program to keep track of a hardware store's inventory. The store sells various items. For each item in the store, the following information is kept: item ID, item name, number of pieces in stock, manufacturer's price of the item, and the s..

  Java program that prompts for the gpa

This assignment will give you practice with interactive programs, if/else statements and methods that return values. Your program will prompt the user for information about two applicants and compute an overall score for each applicant. This is ..

  Create and code a program that uses three parallel numeric

Create and code a program that uses three parallel numeric arrays of size 6. The program searches one of the arrays and then displays the corresponding values from the other two arrays.

  Write program that uses top five countries national wealth

Write a program that uses the top five countries' National Wealth to calculate the average of those five countries.

  Program that computes and prints the value of 6!/5! using

Write a Java program that computes and prints the  value of 6!/5! using Scanner.

  Write a recursive method that takes two non-negative integer

Write a recursive method that takes two non-negative integers m and n as parameters and returns the product.

  Part-11 suppose we have a rectangle class that includes

part-11. suppose we have a rectangle class that includes length and width attributes of type int both set by the

  Shooting star

Initial project folder you will see the beginnings of a Driver - You need to implement that DoubleListOfBlock methods so they perform

  Write a program to compare berlin, tehran and seoul

Write a program to compare Berlin, Tehran and Seoul information with Louisville - Your program should ask the User to select one of the cities with entering their first letters as input, "B" for Berlin, "T" for Tehran and "S" for Seoul.

  Write function in javascript to compute person-s gross pay

Write the function using JavaScript syntax to compute a person's gross pay for a week. The function should receive the number of hours worked and the rate of pay per hour.

  Tic-tac-toe game assignment

Assignment 1(Java): Tic-Tac-Toe Game (Assignment 1 is attached),  Use the concepts and scenario from Assignment 1 and continue with the tic-tac-toe game design and development.  Section 1: Java Program File, The following method, numPaths, is suppos..

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd