









Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!










Docsity.com
trees! For example, here are some trees:
each right sub-tree.
AVL trees
Trees which remain balanced - and thus guarantee
O(logn) search times - in a dynamic environment.
Or more importantly, since any tree can be re-
balanced - but at considerable cost - can be re-
balanced in O(logn) time.
Unbalanced Tree
and only 3 nodes to the right of the root
right sub-tree
become the new root
Unbalanced Tree After 1 Shift Right
Jill
Eric
John
Hank
Carl
Mary
Ann Fred
Gary
Kim Derek
The tree is now balanced 5-5. However the Root->left
subtree is not balanced i.e 3-1 so to correct that we will right
shift Eric
Jill
Eric
John
Gary
Carl
Mary
Ann Hank
Fred
Kim Derek
Jill
Eric
John
Gary
Carl
Mary
Ann Hank
Fred
Kim
Derek
Now we have an AVL Tree