Download presentation
Presentation is loading. Please wait.
Published byNawazish Ali Modified over 5 years ago
2
INSERT THE TITLE OF YOUR PRESENTATION HERE AVL TREE
3
What is AVL TREE The AVL check the height of left and right sub-trees and assume that the difference is not more than 1. Difference mean (Balance factor = Height (left sub-trees) --- Height (right sub-trees) ) AVL is an example of : Balanced Binary Search Trees Def.
4
Introduced When and who was introduced: Named after 2 Russian mathematicians Georgii Adelson-Velsky (1922 - ?) Evgenii Mikhailovich Landis (1921-1997) Who published it 1962 in their paper: “An Algorithms for the organization of information”
5
Advantages of Binary Search Tree Use AVL to keep balance in a tree. Search things with efficient way. If Balanced it is called AVL TREE. A Non empty binary tree is also called AVL TREE
6
Balance factor: Height of left sub tree –Height of right sub tree Range of Balance factor is between (1,0,-1) Every node balance factor is between this range is called AVL TREE. We need to check only ancestors balance factors of a inserted node.
7
Example: 2 4 1 5 3 6 1 L0 L1 L2 2 2 2-2=0
8
Example: 5 1 2 3 4 5 -2 0-2=-2 According to this It’s not AVL tree But we convert it i n AVL tree to some rules
9
Rotation: 1:AVL TREE use rotations to maintain balance. 2:Look the nearest ancestor of the inserted node, whose balance factor is disturb.
10
Types of Rotations: 1: LL Rotation 2: RR Rotation 3:RL Rotation 4:LR Rotation
11
LL Rotation: Used when node is inserted into right sub-tree of right sub-tree. 0 A B C C B C C A Insert new node Balance (0) L-L
12
Right Rotation: Node is inserted in the left of left sub-tree. 0 C C B A A C C B Balance (0) R-R
13
Left – Right Rotation: Node is inserted in the right of left sub-tree and make the tree unbalanced. 0 C C B A C C B A L-R BA C C R-R 4 2 3 4 3 2 2 Binary tree
14
Right-Left Rotation: Node is inserted into left of right sub-tree. 0 A B C C A C C B C C BA L-R R-R
15
Any Questions………………..???
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.