Question: Objectives: AVL Tree Implementation Write a program to build an AVL tree by accepting the integers input from users. For each input, balance the tree
Objectives: AVL Tree Implementation
Write a program to build an AVL tree by accepting the integers input from users. For each input, balance the tree and display it on the screen; you then
calculate the preorder, indorder and postoder traversals as well. There should be a menu to drive the program. It should be similar as follows:
AVL Tree Implementation
A: Insert an integer to a tree and show the balanced tree at each insertion.
B: Display the balanced tree and show preorder traversal.
C: Display the balanced tree and show inorder traversal.
D: Display the balanced tree and show postorder traversal.
E: Exit
To be sure, your program is correctly working, use the following data to test AVL tree:
You should perform more test with different data sets.
Sample output of AVL Home Work
AVL Tree Implemenation
A: Insert an integer to tree and show the balanced tree at each insertion.
B: Display the balanced tree and show preorder traversal.
C: Display the balanced tree and show inorder traversal.
D: Display the balanced tree and show postorder traversal.
E: Exit
A
Enter integer to be added to tree:
Node inserted
AVL Tree Implemenation
A: Insert an integer to tree and show the balanced tree at each insertion.
B: Display the balanced tree and show preorder traversal.
C: Display the balanced tree and show inorder traversal.
D: Display the balanced tree and show postorder traversal.
E: Exit
A
Enter integer to be added to tree:
Node inserted
v
AVL Tree Implemenation
A: Insert an integer to tree and show the balanced tree at each insertion.
B: Display the balanced tree and show preorder traversal.
C: Display the balanced tree and show inorder traversal.
D: Display the balanced tree and show postorder traversal.
E: Exit
A
Enter integer to be added to tree:
Node inserted
AVL Tree Implemenation
A: Insert an integer to tree and show the balanced tree at each insertion.
B: Display the balanced tree and show preorder traversal.
C: Display the balanced tree and show inorder traversal.
D: Display the balanced tree and show postorder traversal.
E: Exit
A
Enter integer to be added to tree:
Node inserted
vv
vn
AVL Tree Implemenation
A: Insert an integer to tree and show the balanced tree at each insertion.
B: Display the balanced tree and show preorder traversal.
C: Display the balanced tree and show inorder traversal.
D: Display the balanced tree and show postorder traversal.
E: Exit
A
Enter integer to be added to tree:
Node inserted
AVL Tree Implemenation
A: Insert an integer to tree and show the balanced tree at each insertion.
B: Display the balanced tree and show preorder traversal.
C: Display the balanced tree and show inorder traversal.
D: Display the balanced tree and show postorder traversal.
E: Exit
A
Enter integer to be added to tree:
Node inserted
Tree has been rebalanced
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
