Question

There are N numbers in the sequence. Please insert those numbers into an empty AVL tree...

There are N numbers in the sequence.

Please insert those numbers into an empty AVL tree one by one.

After the AVL tree has been constructed:

(1) Input:

N

The sequence of numbers

Number which will be deleted from the tree

(2) Print out

The sequence of the tree by pre-order traversal

The sequence of the tree by in-order traversal

The sequence of the tree by post-order traversal

NEW TREE AFTER DELETING number

The sequence of the tree by pre-order traversal

The sequence of the tree by in-order traversal

The sequence of the tree by post-order traversal

(3) Try to delete the number provided from the tree, and then print out the tree with tree different methods of traversal described above.

Source: C++

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer: AVL-TREE: AVL tree is a self-balancing Binary Search Tree (BST) where the difference between heights of left and righ#define pow2(n) (1 << (n)) using namespace std; * Node Declaration struct avl node int data; struct avl node left; struct avlAn Example Tree that is an AVL Tree 8 18 5 4An Example Tree that is NOT an AVL Tree 12 8 18 5 2* Height Difference int avlTree::diff(avl node *temp) int 1 height -height(temp->left); int r_height -height(temp-right); intavl node *avlTree::lr rotation(avl node *parent) avl node *temp; temp - parent->left; parent->left-rr rotation(temp): returnreturn temp; Insert Element into the tree avl node *avlTree::insert(avl node *root, int value) if (root NULL) root= new avi ncout << Root ->. for (i-0; i < level && ptr !- root; i++) cout << cout << ptr->data; display(ptr->left, level + 1); Inordeavl.inorder(root); cout << endl; break; case 4: cout << Preorder Traversal: << endl; avl.preorder(root); cout << endl; brea

Add a comment
Know the answer?
Add Answer to:
There are N numbers in the sequence. Please insert those numbers into an empty AVL tree...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT