Presentation is loading. Please wait.

Presentation is loading. Please wait.

INSERT THE TITLE OF YOUR PRESENTATION HERE:

Similar presentations


Presentation on theme: "INSERT THE TITLE OF YOUR PRESENTATION HERE:"— Presentation transcript:

1

2 INSERT THE TITLE OF YOUR PRESENTATION HERE Nawazish Ali 17251519-039 Ali Abbas Noor 17251519-035 Talha Ijaz 16171519-051

3 INSERT THE TITLE OF YOUR PRESENTATION HERE AVL TREE

4 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.

5 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”

6 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

7 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.

8 Example: 2 4 1 5 3 6 1 L0 L1 L2 2 2 2-2=0

9 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

10 Rotation: 1:AVL TREE use rotations to maintain balance. 2:Look the nearest ancestor of the inserted node, whose balance factor is disturb.

11 Types of Rotations: 1: LL Rotation 2: RR Rotation 3:RL Rotation 4:LR Rotation

12 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

13 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

14 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

15 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

16 Any Questions………………..???

17


Download ppt "INSERT THE TITLE OF YOUR PRESENTATION HERE:"

Similar presentations


Ads by Google