Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please help me write this code in Java 8 about implementing an AVL tree using nodes. The question shows sample code in C++, but the

Please help me write this code in Java 8 about implementing an AVL tree using nodes. The question shows sample code in C++, but the final code should be written in Java 8. Please make sure that the code meets all the needed requirements. Also, include screenshots of your input and output. Thank You!

image text in transcribedYou can find the Binary Search Tree (BST) Homework #1 code mentioned above here: pastebin.com/5A2FxfmX

image text in transcribed

image text in transcribed

image text in transcribed

-----------------------------------------------------------------------------------------------

These are the sample inputs entered and then the output that was outputted. Your output should match the sample outputs below after entering the sample inputs given.

Sample Input 0

17 insert 5 levelorder insert 3 levelorder insert 2 levelorder insert 9 levelorder insert 1 levelorder insert 7 levelorder insert 0 levelorder lookup 5 lookup 6 lookup 7 

Sample Output 0

5(0) 5(1) 3(0) 3(0) 2(0) 5(0) 3(-1) 2(0) 5(-1) 9(0) 3(0) 2(1) 5(-1) 1(0) 9(0) 3(0) 2(1) 7(0) 1(0) 5(0) 9(0) 3(0) 1(0) 7(0) 0(0) 2(0) 5(0) 9(0) 1 0 1 

Sample Input 1

23 insert 5 insert 3 insert 2 insert 9 insert 1 insert 7 insert 0 insert 15 insert 4 insert 8 levelorder delete 15 levelorder delete 8 levelorder delete 9 levelorder delete 0 levelorder lookup 15 lookup 23 lookup 9 lookup 5 

Sample Output 1

3(-1) 1(0) 7(0) 0(0) 2(0) 5(1) 9(0) 4(0) 8(0) 15(0) 3(-1) 1(0) 7(0) 0(0) 2(0) 5(1) 9(1) 4(0) 8(0) 3(-1) 1(0) 7(1) 0(0) 2(0) 5(1) 9(0) 4(0) 3(0) 1(0) 5(0) 0(0) 2(0) 4(0) 7(0) 3(0) 1(-1) 5(0) 2(0) 4(0) 7(0) 0 0 0 1 

Sample Input 2

23 insert 5 insert 3 insert 2 insert 9 insert 1 insert 7 insert 0 insert 15 insert 4 insert 8 levelorder delete 4 levelorder delete 2 levelorder delete 7 levelorder delete 0 levelorder lookup 4 lookup 23 lookup 0 lookup 5 

Sample Output 2

3(-1) 1(0) 7(0) 0(0) 2(0) 5(1) 9(0) 4(0) 8(0) 15(0) 3(-1) 1(0) 7(-1) 0(0) 2(0) 5(0) 9(0) 8(0) 15(0) 3(-1) 1(1) 7(-1) 0(0) 5(0) 9(0) 8(0) 15(0) 3(-1) 1(1) 8(-1) 0(0) 5(0) 9(-1) 15(0) 8(0) 3(0) 9(-1) 1(0) 5(0) 15(0) 0 0 0 1 

Sample Input 3

16 insert 15 insert 8 insert 22 insert 3 insert 10 insert 18 insert 29 insert 5 insert 24 levelorder delete 10 levelorder lookup 10 lookup 8 lookup 5 lookup 15 

Sample Output 3

15(0) 8(1) 22(-1) 3(-1) 10(0) 18(0) 29(1) 5(0) 24(0) 15(-1) 5(0) 22(-1) 3(0) 8(0) 18(0) 29(1) 24(0) 0 1 1 1 

Sample Input 4

16 insert 15 insert 8 insert 22 insert 3 insert 10 insert 18 insert 29 insert 5 insert 18 levelorder delete 18 levelorder lookup 24 lookup 22 lookup 18 lookup 15 

Sample Output 4

15(0) 8(1) 22(-1) 3(-1) 10(0) 18(0) 29(1) 5(0) 24(0) 15(1) 8(1) 24(0) 3(-1) 10(0) 22(0) 29(0) 5(0) 1 1 0 1
For this assignment, you will implement an AVL tree using nodes. For example, in C++, the node and class definitions would look like: struct Node int data; Node left; Node *right; int height; b: class AVL Node *root; You will need to implement lookup, which returns a boolean indicating whether the target was found (this will be the same as for your BST in Homework #1), insert, which adds an item to the AVL tree, remove, which removes an item from the AVL, and a level-order traversal (which will also be the same as for your BST) which prints the tree in the appropriate order. For example, in C++, the function headers would be the following: For this assignment, you will implement an AVL tree using nodes. For example, in C++, the node and class definitions would look like: struct Node int data; Node left; Node *right; int height; b: class AVL Node *root; You will need to implement lookup, which returns a boolean indicating whether the target was found (this will be the same as for your BST in Homework #1), insert, which adds an item to the AVL tree, remove, which removes an item from the AVL, and a level-order traversal (which will also be the same as for your BST) which prints the tree in the appropriate order. For example, in C++, the function headers would be the following

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David Kroenke, David Auer, Scott Vandenberg, Robert Yoder

9th Edition

0135188148, 978-0135188149, 9781642087611

More Books

Students also viewed these Databases questions

Question

4. Design a career management system.

Answered: 1 week ago

Question

4. Evaluation is ongoing and used to improve the system.

Answered: 1 week ago

Question

6. Effectively perform the managers role in career management.

Answered: 1 week ago