This document presents information about AVL trees through a slideshow presentation. It begins by defining AVL trees as binary search trees where the heights of the subtrees of any node differ by at most 1. It then discusses that AVL trees ensure searching, insertion, and deletion take O(log N) time by keeping the tree balanced through rotations. The presentation notes that AVL trees remain balanced through single and double rotations during insertions and deletions, and that rebalancing can be done in O(log N) time. It concludes by emphasizing that AVL trees guarantee O(log N) search time in dynamic environments through maintaining balance.
AVL Trees: An Introduction to Self-Balancing Binary Search Trees
1. Presentation On :
AVL TREES
Group Member:
Chhatra Thapa (Sid:10935)
Susat Maharjan (Sid:10954)
1
2. AVL TREE IS…
• named after Adelson-Velskii and Landis
• the first dynamically balanced trees to be propose
• Binary search tree with balance condition in which the sub-trees of
each node can differ by at most 1 in their height
2
3. DEFINITION OF A BALANCED TREE
• Ensure the depth = O(log N)
• Take O(log N) time for searching, insertion, and deletion
• Every node must have left & right sub-trees of the same height
• Goal: keep the height of a binary search tree O(log N).
3
4. AN AVL TREE HAS THE FOLLOWING PROPERTIES:
• Sub-trees of each node can differ by at most 1 in their height
• Every sub-trees is an AVL tree
4
5. AVL TREE?
YES NO
Each left sub-tree has Left sub-tree has height 3,
height 1 greater than but right sub-tree has
each right sub-tree height 1
5
6. INSERTION AND DELETIONS
• It is performed as in binary search trees
• If the balance is destroyed, rotation(s) is performed to correct
balance
• For insertions, one rotation is sufficient
• For deletions, O(log n) rotations at most are needed
6
7. Single Rotation
left sub-tree is one level move ① up a level and
deeper than the right sub-tree ② down a level
7
15. KEY POINTS
• AVL tree remain balanced by applying rotations, therefore it
guarantees O(log N) search time in a dynamic environment
• Tree can be re-balanced in at most O(log N) time
15
The AVL tree is named after its two Soviet inventors, G. M. Adelson-Velskii and E. M. Landis, who published it in their 1962 paper "An algorithm for the organization of information.AVL trees are binary search trees that balances itself every time an element is inserted or deleted.
Balanced Tree -Suggestion 1: the left and right subtrees of root have the same height -Suggestion 2: every node must have left and right subtrees of the same heightEach node of an AVL tree has the property that the heights of the sub-tree rooted at its children differ by at most one.We want a tree with small height.Height of a binary tree with N node is at least(log N) .Goal: keep the height of a binary search tree O(log N).Balanced binary search trees
AVL tree approximates the ideal tree (completely balanced tree).AVL Tree maintains a height close to the minimum. Suppose h = 5 Then , left sub-tree height should be 4 right sub-tree height should be 3
An update (insert or remove) in an AVL tree could destroy the balance. It must then be rebalanced before the operation can be considered complete.