Design and write a complete test program to test if the AVLTree class in Listing 26.4 meets
Question:
Design and write a complete test program to test if the AVLTree class in Listing 26.4 meets all requirements.
Listing
Transcribed Image Text:
1 public class TestAVLTree { public static void main(String[] args) { // Create an AVL tree AVLTree
1 public class TestAVLTree { public static void main(String[] args) { // Create an AVL tree AVLTree tree = new AVLTree<>(new Integer[]{25, 20, 5}); System.out.print("After inserting 25, 20, 5:"); printTree (tree); 3 4 8 tree.insert(34); tree.insert(50); System.out.print("\nAfter inserting 34, 50:"); printTree(tree); 10 11 12 13 14 tree.insert(30); System.out.print("\nAfter inserting 30"); printTree(tree); 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 tree.insert(10); System.out.print("\nAfter inserting 10"); printTree(tree); tree.delete(34); tree.delete(30); tree.delete(50); System.out.print("\nAfter removing 34, 30, 50:"); printTree(tree); tree.delete(5); System.out.print("\nAfter removing 5:"); printTree(tree); System.out.print("\nTraverse the elements in the tree: "); for (int e: tree) { System.out.print(e + " "); 34 35 36 37 38 public static void printTree(BST tree) { // Traverse tree System.out.print("\nInorder (sorted): "); tree.inorder); System.out.print("\nPostorder: "); tree.postorder(); System.out.print("\nPreorder: "); tree.preorder(); System.out.print("\nThe number of nodes is 39 40 41 41 43 44 45 + tree.getSize()); 46 nw3wmmmm
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Answer rating: 64% (14 reviews)
Program Plan Create a TestAVLTree class refers to the text book for these fore classes BST clas AVLTree class AbstractTree and Tree class Create a printTreeMethod method to print AVL tree printTreeMet...View the full answer
Answered By
PALASH JHANWAR
I am a Chartered Accountant with AIR 45 in CA - IPCC. I am a Merit Holder ( B.Com ). The following is my educational details.
PLEASE ACCESS MY RESUME FROM THE FOLLOWING LINK: https://drive.google.com/file/d/1hYR1uch-ff6MRC_cDB07K6VqY9kQ3SFL/view?usp=sharing
3.80+
3+ Reviews
10+ Question Solved
Related Book For
Introduction to Java Programming, Comprehensive Version
ISBN: 978-0133761313
10th Edition
Authors: Y. Daniel Liang
Question Posted:
Students also viewed these Computer science questions
-
Design and write a complete test program to test if the BST class in Listing 25.5 meets all requirements. Listing 1 public class BST 2 extends AbstractTree { protected TreeNode root; protected int...
-
Design and write a complete test program to test if the MyLinkedList class in Listing 24.6 meets all requirements. Listing 1 public class MyLinkedList extends MyAbstractlist { private Node head,...
-
Design and write a complete test program to test if the MyArrayList class in Listing 24.3 meets all requirements. Listing 1 public class MyArrayList extends MyAbstractList { public static final int...
-
Your client, Mr. Brakes Inc., owns and operates an auto-motive repair shop in Cooperstown, New York. Mr. Brakes specializes in replacing and repairing brakes on cars, sport utility vehicles, and...
-
A sequence (xn) in Rn converges if and only if each of its components xni converges in R.
-
Goods and services that are produced and consumed within the same household are not included in GDP calculations. Economists refer to the production of these goods and services as household...
-
Show that during the early part of the electron-positron annihilation era, the ratio of the electron number density to the photon number density scaled with temperature as \[\frac{n_{-}}{n_{\gamma}}...
-
(Pension Expense, Journal Entries, Statement Presentation) Ferrari Company received the following selected information from its pension plan trustee concerning the operation of the company's defined...
-
A 25-year-old Latin, G1P1, cisfemale presents to the office with a 6-month history of amenorrhea; reports having regular menstrual cycles every month up until about 1 year ago when her menstrual...
-
Drums, bins, boxes, and other containers that are used in the petroleum industry are sold by Holden Inc. One of the companys products is a heavy-duty, environmentally friendly, corrosion-resistant...
-
Create a new concrete class that implements MyMap using open addressing with linear probing. For simplicity, use f(key) = key % size as the hash function, where size is the hash-table size....
-
Suppose that the TreeNode class defined in BST contains a reference to the node?s parent, as shown in Programming Exercise 25.15. Implement the AVLTree class to support this change. Write a test...
-
What potential benefits might be achieved if U.S. firms are allowed to use IFRS?
-
Explain what is meant by monetary policy. List and explain the 3 tools the Federal Reserve has to conduct monetary policy.
-
suppose that when the price of donuts rises 10%, the quantity demanded of donuts falls 3%.Based on his information, what is the approximate absolute price elasticity of demand for donuts
-
What is most likely to happen when firms in an import-competing infant industry are offered subsidies? Explain
-
Describe the process that makes the central bank decides the amount of money it prints?
-
Explain why governments borrowing to undertake expansionary fiscal policy can also make it easier for central banks to conduct expansionary monetary policy.
-
Record the sale on account, for $1,600, of merchandise costing $900 in the province of Quebec. Assume the company uses a perpetual inventory system. The QST is 9.975%?
-
The Adjusted Trial Balance columns of a 10-column work sheet for Webber Co. follow. Complete the work sheet by extending the account balances into the appropriate financial statement columns and by...
-
If the vertices of the graph from Figure 14.11 are ordered as (JFK, LAZ, MIA, BOS, ORD, SFO, DFW), in what order would edges be added to the transitive closure during the Floyd-Warshall algorithm?...
-
Compute a topological ordering for the directed graph drawn with solid edges in Figure 14.3d. BOS ORD JFK SFO (DFW (LAX MIA (d)
-
Bob loves foreign languages and wants to plan his course schedule for the following years. He is interested in the following nine language courses: LA15, LA16, LA22, LA31, LA32, LA126, LA127, LA141,...
-
If a family spends its entire budget in a given time frame, the family can afford either 8 dance lessons or 5 karate lessons. Assuming the family spends its entire budget on just these two goods,...
-
Part 5 - Stretch Your Thinking- Answer the questions 18. Applying the least-cost rule is similar to applying the utility maximizing rule. Identify two similarities and two differences regarding these...
-
If today's youth learn the skills that they need to work in the global workforce before they leave school, then the economic crisis will end because unemployment will be greatly reduced." What...
Study smarter with the SolutionInn App