SlideShare a Scribd company logo
Presentation On :




                    AVL TREES


Group Member:
Chhatra Thapa (Sid:10935)
Susat Maharjan (Sid:10954)
                                1
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
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
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
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
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
Single Rotation




 left sub-tree is one level       move ① up a level and
 deeper than the right sub-tree   ② down a level
                                                  7
Single rotation : Rotate right




                                 8
Single rotation : Rotate left




                                9
Double Rotation




Left sub-tree is two level       Move ② up two levels and
deeper than the right sub-tree   ③ down a level
                                                 10
Insertion



            Insert 6



                       Imbalance at 8
                       Perform rotation with 7




                                      11
12
Deletion



                          Delete 4


                                     Imbalance at 3
                                     Perform rotation with 2




Imbalance at 5
Perform rotation with 8                             13
14
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
THANK YOU
    

            16

More Related Content

PPT
PPTX
Avl trees
PPTX
Tree Traversal
PPTX
AVL Tree Data Structure
PPT
Red black tree
PPTX
AVL Tree in Data Structure
PPT
BINARY TREE REPRESENTATION.ppt
PPT
Binary tree
Avl trees
Tree Traversal
AVL Tree Data Structure
Red black tree
AVL Tree in Data Structure
BINARY TREE REPRESENTATION.ppt
Binary tree

What's hot (20)

PPTX
single linked list
PPTX
trees in data structure
PDF
Red black tree
PPTX
Binary Tree in Data Structure
PPTX
Logical and shift micro operations
PPTX
Search tree,Tree and binary tree and heap tree
PPT
Binomial Heaps
PDF
Binary Search - Design & Analysis of Algorithms
PPTX
Trees data structure
PPTX
Binomial heap presentation
PPTX
PPTX
Binomial Heap
PPTX
Avl trees
PPTX
Threaded Binary Tree.pptx
PPTX
Joins And Its Types
PPT
B trees dbms
PPTX
Tree in data structure
PDF
Fibonacci Heap
PPT
B trees and_b__trees
single linked list
trees in data structure
Red black tree
Binary Tree in Data Structure
Logical and shift micro operations
Search tree,Tree and binary tree and heap tree
Binomial Heaps
Binary Search - Design & Analysis of Algorithms
Trees data structure
Binomial heap presentation
Binomial Heap
Avl trees
Threaded Binary Tree.pptx
Joins And Its Types
B trees dbms
Tree in data structure
Fibonacci Heap
B trees and_b__trees
Ad

Viewers also liked (8)

PPTX
Natural Vegetation
PPTX
Trees (data structure)
PPT
Avl tree
PPT
Avl trees 2
PDF
10 de-thi-hsg-toan-10-co-dap-an
PDF
Trees, Binary Search Tree, AVL Tree in Data Structures
PPTX
Tree plantation
Natural Vegetation
Trees (data structure)
Avl tree
Avl trees 2
10 de-thi-hsg-toan-10-co-dap-an
Trees, Binary Search Tree, AVL Tree in Data Structures
Tree plantation
Ad

Similar to AVL Tree (9)

PPTX
AVL Tree of Data Structure presentation.pptx
PPTX
Lec 08 - Balanced BSTs and AVL Tree.pptx
PPTX
Avl tree ppt
PDF
Balanced
PPT
3-avl-tree.ppt
PPT
M.E - Computer Science and Engineering-Data structure avl-tree
PPTX
AVL TREES for data structures import.pptx
PPTX
Avl tree
AVL Tree of Data Structure presentation.pptx
Lec 08 - Balanced BSTs and AVL Tree.pptx
Avl tree ppt
Balanced
3-avl-tree.ppt
M.E - Computer Science and Engineering-Data structure avl-tree
AVL TREES for data structures import.pptx
Avl tree

AVL Tree

  • 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
  • 8. Single rotation : Rotate right 8
  • 9. Single rotation : Rotate left 9
  • 10. Double Rotation Left sub-tree is two level Move ② up two levels and deeper than the right sub-tree ③ down a level 10
  • 11. Insertion Insert 6 Imbalance at 8 Perform rotation with 7 11
  • 12. 12
  • 13. Deletion Delete 4 Imbalance at 3 Perform rotation with 2 Imbalance at 5 Perform rotation with 8 13
  • 14. 14
  • 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
  • 16. THANK YOU  16

Editor's Notes

  • #3: 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.
  • #4: 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
  • #5: 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
  • #7: 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.