380 likes | 469 Views
This presentation is based on the AVL tree in Data Structure. This tutorial explains what is an AVL tree in data structure and will help beginners with the fundamentals of Data structure. The video also covers practical demo for a better learning experience.<br>
E N D
Agenda AVL Tree
Agenda AVL Tree What is AVL Tree?
AVL Tree in Data Structures Click here to watch the video
Agenda Rotations in AVL Tree What is AVL Tree? AVL Tree
Agenda Rotations in AVL Tree Complexity What is AVL Tree? AVL Tree
Agenda Rotations in AVL Tree Complexity What is AVL Tree? AVL Tree Operations
Agenda Rotations in AVL Tree Complexity What is AVL Tree? AVL Tree Operations Conclusion
What is a AVL Tree? • A AVL tree is a height balanced binary search tree in which height of left sub tree and right subtree can differ at most by one. • Balance factor(x) = | height(left(x)) – height(right(x)) |
Rotations in Binary Trees • We can perform Four type of Rotations on a AVL Tree • LL Rotation • RR Rotation • LR Rotation • RL Rotation
Rotations in Binary Trees LL Rotation
Rotations in Binary Trees LL Rotation
Rotations in Binary Trees RR Rotation
Rotations in Binary Trees RR Rotation
Rotations in Binary Trees • LR Rotation • LR=RR+LL
Rotations in Binary Trees • LR Rotation • LR=RR+LL
Rotations in Binary Trees • LR Rotation • LR=RR+LL
Rotations in Binary Trees • RL Rotation • RL=LL+RR
Rotations in Binary Trees • RL Rotation • RL=LL+RR
Rotations in Binary Trees • RL Rotation • RL=LL+RR
Complexity Space Complexity of AVL trees = O(n) Search Complexity of AVL Trees = O(log n) insertion Complexity of AVL Trees = O(log n) Deletion Complexity of AVL Trees = O(log n)
Operations Insertion Deletion
Operations Insertion Deletion
Operations Insertion Deletion
Conclusion AVL Tree is a self balancing Binary search tree. Balance factor of each node must be either -1, 0 or 1. After every step, We need to verify its balance factor. It is faster at insertion and deletion operation.