An AVL tree is a binary search tree that is height balanced: for each node x, the heights of the left and right subtrees of x differ by at most 1. To implement an AVL tree, we maintain an extra attribute in each node: x. h is the height of node x. As for any other binary search tree T, we assume that T. root points to the root node.
a. Prove that an AVL tree with n nodes has height O(lg n).
b. To insert into an AVL tree, we first place a node into the appropriate place in binary search tree order. Afterward, the tree might no longer be height balanced. Specifically, the heights of the left and right children of some node might differ by 2. Describe a procedure BALANCE(x), which takes a subtree rooted at x whose left and right children are height balanced and have heights that differ by at most 2, i.e., x. right. h – x. left. h = 2, and alters the subtree rooted at x to be height balanced.
c. Using part (b), describe a recursive procedure AVL-INSERT(x, ) that takes a node x within an AVL tree and a newly created node z(whose key has already been filled in), and adds zto the subtree rooted at x, maintaining the property that x is the root of an AVL tree. As in TREE-INSERT from Section 12.3, assume that z.key has already been filled in and that z.left = NIL and z.right = NIL; also assume that z.h = 0. Thus, to insert the node zinto the AVL tree T, we call AVL-INSERT(T.root, z ).
d. Show that AVL- INSERT, run on an n-node AVL tree, takes O(lg n) time and performs O(1) rotations.
Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.
You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.Read more
Each paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.Read more
Thanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.Read more
Your email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.Read more
By sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.Read more