Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Java Expert


Home >> Java

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.

Java, Programming

  • Category:- Java
  • Reference No.:- M91377059
  • Price:- $50

Priced at Now at $50, Verified Solution

Have any Question?


Related Questions in Java

Assignment - method in our madnessthe emphasis for this

Assignment - "Method in our Madness" The emphasis for this assignment is methods with parameters. In preparation for this assignment, create a folder called Assign_3 for the DrJava projects for the assignment. A Cityscap ...

Overviewyou are required to use java se 80 and javafx to

Overview You are required to use Java SE 8.0 and JavaFX to develop a Graphical User Interface (GUI) for the FlexiRent rental property management program created in Assignment 1. This assignment is designed to help you: 1 ...

Project requirementsfor the problem described in the next

Project requirements For the problem described in the next section, you must do the following: 1. include your student ID at the end of all filenames for all java code files. Three classes have been identified in section ...

Question slideshows or carousels are very popular in

Question : Slideshows (or carousels) are very popular in websites. They allow web developers to display news or images on the website in limited space. In this code challenge, you are required to complete the JavaScript ...

Assignment taskwrite a java console application that allows

Assignment task Write a java console application that allows the user to read, validate, store, display, sort and search data such as flight departure city (String), flight number (integer), flight distance (integer), fl ...

Assessment socket programmingtaskwrite a java gui program

Assessment: Socket Programming Task Write a JAVA GUI program that would facilitate text chatting/exchanging between two or multiple computers over the network/internet, using the concept of JAVA socket programming. If yo ...

Operating systems assignment -problem 1 sharing the bridgea

Operating Systems Assignment - Problem 1: Sharing the Bridge A new single lane bridge is constructed to connect the North Island of New Zealand to the South Island of New Zealand. Farmers from each island use the bridge ...

Assignment game prototypeoverviewfor this assessment task

Assignment: Game Prototype Overview For this assessment task you are expected to construct a prototype level/area as a "proof of concept" for the game that you have designed in Assignment 1. The prototype should function ...

Assessment instructionsin this assessment you will design

Assessment Instructions In this assessment, you will design and code a simple Java application that defines a class, instantiate the class into a number of objects, and prints out the attributes of these objects in a spe ...

Assessment database and multithread programmingtasktask 1

Assessment: Database and Multithread Programming Task Task 1: Grade Processing University grading system maintains a database called "GradeProcessing" that contains number of tables to store, retrieve and manipulate stud ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As