SlideShare a Scribd company logo
AVL TREE
Prof. Manjusha Amritkar
Information Technology Department
International Institute of Information Technology, I²IT
www.isquareit.edu.in
Binary Search Tree
• E.g. 2,4,6,8,10
• Right skewed tree
• Time needed to perform insertion ,deletion and many other
operations is O(N) in worst case.
• We need tree with small height with Log N
• Such trees are called as Balanced Binary Search Tree
• e.g AVL tree, Red Black Tree
International Institute of Information Technology, I²IT, P-14, Rajiv Gandhi Infotech Park, Hinjawadi Phase 1, Pune - 411 057
Phone - +91 20 22933441/2/3 | Website - www.isquareit.edu.in | Email - info@isquareit.edu.in
2
4
6
8
10
AVL Tree
• AVL tree Named after their inventor Adelson, Velski &
Landis, is a self-balancing Binary Search Tree (BST) where
the difference between heights of left and right subtrees
cannot be more than one for all nodes.
• The difference between the heights is called
as balanced factor (BF)
• BF = height (left subtree) – height (right subtree)
• The tree is balanced when BF is -1, 0, 1
International Institute of Information Technology, I²IT, P-14, Rajiv Gandhi Infotech Park, Hinjawadi Phase 1, Pune - 411 057
Phone - +91 20 22933441/2/3 | Website - www.isquareit.edu.in | Email - info@isquareit.edu.in
AVL Tree Rotations
• If the difference is more than one then the tree is to be
balanced using rotations.
• Left rotation (LL)
Right rotation (RR)
Left-Right rotation (LR)
Right-Left rotation (RL)
International Institute of Information Technology, I²IT, P-14, Rajiv Gandhi Infotech Park, Hinjawadi Phase 1, Pune - 411 057
Phone - +91 20 22933441/2/3 | Website - www.isquareit.edu.in | Email - info@isquareit.edu.in
Left Rotation
• If a tree becomes unbalanced, when a node is inserted into the
right subtree of the right subtree, then we perform a single
left rotation
International Institute of Information Technology, I²IT, P-14, Rajiv Gandhi Infotech Park, Hinjawadi Phase 1, Pune - 411 057
Phone - +91 20 22933441/2/3 | Website - www.isquareit.edu.in | Email - info@isquareit.edu.in
Right Rotation
• AVL tree may become unbalanced, if a node is inserted in the
left subtree of the left subtree. The tree then needs a right
rotation
International Institute of Information Technology, I²IT, P-14, Rajiv Gandhi Infotech Park, Hinjawadi Phase 1, Pune - 411 057
Phone - +91 20 22933441/2/3 | Website - www.isquareit.edu.in | Email - info@isquareit.edu.in
Left Right Rotations
• A node has been inserted into the right subtree of the left
subtree. This makes C an unbalanced node. These scenarios
cause AVL tree to perform left-right rotation.
International Institute of Information Technology, I²IT, P-14, Rajiv Gandhi Infotech Park, Hinjawadi Phase 1, Pune - 411 057
Phone - +91 20 22933441/2/3 | Website - www.isquareit.edu.in | Email - info@isquareit.edu.in
LR Rotation
Right Left Rotations
• A node has been inserted into the left subtree of the right
subtree. This makes A, an unbalanced node with balance factor
2.
International Institute of Information Technology, I²IT, P-14, Rajiv Gandhi Infotech Park, Hinjawadi Phase 1, Pune - 411 057
Phone - +91 20 22933441/2/3 | Website - www.isquareit.edu.in | Email - info@isquareit.edu.in
RL Rotation
Example: Construct an AVL Tree by inserting numbers
from 1 to 8.
International Institute of Information Technology, I²IT, P-14, Rajiv Gandhi Infotech Park, Hinjawadi Phase 1, Pune - 411 057
Phone - +91 20 22933441/2/3 | Website - www.isquareit.edu.in | Email - info@isquareit.edu.in
Example: Construct an AVL Tree by inserting numbers
from 1 to 8.
International Institute of Information Technology, I²IT, P-14, Rajiv Gandhi Infotech Park, Hinjawadi Phase 1, Pune - 411 057
Phone - +91 20 22933441/2/3 | Website - www.isquareit.edu.in | Email - info@isquareit.edu.in
Example: Construct an AVL Tree by inserting numbers
from 1 to 8.
International Institute of Information Technology, I²IT, P-14, Rajiv Gandhi Infotech Park, Hinjawadi Phase 1, Pune - 411 057
Phone - +91 20 22933441/2/3 | Website - www.isquareit.edu.in | Email - info@isquareit.edu.in
Example: Construct an AVL Tree by inserting numbers
from 1 to 8.
International Institute of Information Technology, I²IT, P-14, Rajiv Gandhi Infotech Park, Hinjawadi Phase 1, Pune - 411 057
Phone - +91 20 22933441/2/3 | Website - www.isquareit.edu.in | Email - info@isquareit.edu.in
Example: Construct an AVL Tree by inserting numbers
from 1 to 8.
International Institute of Information Technology, I²IT, P-14, Rajiv Gandhi Infotech Park, Hinjawadi Phase 1, Pune - 411 057
Phone - +91 20 22933441/2/3 | Website - www.isquareit.edu.in | Email - info@isquareit.edu.in
Example: Construct an AVL Tree by inserting numbers
from 1 to 8.
International Institute of Information Technology, I²IT, P-14, Rajiv Gandhi Infotech Park, Hinjawadi Phase 1, Pune - 411 057
Phone - +91 20 22933441/2/3 | Website - www.isquareit.edu.in | Email - info@isquareit.edu.in
Example: Construct an AVL Tree by inserting numbers
from 50,25,10,5,7,3,30,20,8,15.
• Insert 50
• Insert 25
50
0
Tree is balanced
50
1
Tree is balanced
25
0
International Institute of Information Technology, I²IT, P-14, Rajiv Gandhi Infotech Park, Hinjawadi Phase 1, Pune - 411 057
Phone - +91 20 22933441/2/3 | Website - www.isquareit.edu.in | Email - info@isquareit.edu.in
Example: Construct an AVL Tree by inserting numbers
from 50,25,10,5,7,3,30,20,8,15.
• Insert 10
Tree is imbalanced
Tree is balanced
International Institute of Information Technology, I²IT, P-14, Rajiv Gandhi Infotech Park, Hinjawadi Phase 1, Pune - 411 057
Phone - +91 20 22933441/2/3 | Website - www.isquareit.edu.in | Email - info@isquareit.edu.in
50
2
25
1
10
0
25
1
10
0
50
0
RR Rotation
Example: Construct an AVL Tree by inserting numbers
from 50,25,10,5,7,3,30,20,8,15.
• Insert 5 insert 7
Tree is balanced
Tree is imbalanced
25
1
10
1
50
0
5
0
25
1
7
0
50
0
5
0
10
0
Tree is balanced
International Institute of Information Technology, I²IT, P-14, Rajiv Gandhi Infotech Park, Hinjawadi Phase 1, Pune - 411 057
Phone - +91 20 22933441/2/3 | Website - www.isquareit.edu.in | Email - info@isquareit.edu.in
25
2
10
2
50
0
5
-1
7
0
LR Rotation
Example: Construct an AVL Tree by inserting numbers
from 50,25,10,5,7,3,30,20,8,15.
Tree is imbalanced
25
2
7
1
50
0
5
1
7
0
5 25
0
3
0 0
Tree is balanced
10
0
3
0
50
0
1
10
International Institute of Information Technology, I²IT, P-14, Rajiv Gandhi Infotech Park, Hinjawadi Phase 1, Pune - 411 057
Phone - +91 20 22933441/2/3 | Website - www.isquareit.edu.in | Email - info@isquareit.edu.in
• Insert 3
LL Rotation
Example: Construct an AVL Tree by inserting numbers
from 50,25,10,5,7,3,30,20,8,15.
• Insert 30 insert 20
Tree is imbalanced
Tree is balanced
7
-1
5 25
-1
3
0 0
50
1
1
10
0
30
20
0
10
0
7 25
0
5
1
1
50
0
1
0
30 50
0
8
15
0
0
3
0
International Institute of Information Technology, I²IT, P-14, Rajiv Gandhi Infotech Park, Hinjawadi Phase 1, Pune - 411 057
Phone - +91 20 22933441/2/3 | Website - www.isquareit.edu.in | Email - info@isquareit.edu.in
7
-2
5 25
1
3
0 -1
50
1
1
10
30
1
20
15
8
RL Rotation
References
• http://www.btechsmartclass.com/data_structures/avl-trees.html
International Institute of Information Technology, I²IT, P-14, Rajiv Gandhi Infotech Park, Hinjawadi Phase 1, Pune - 411 057
Phone - +91 20 22933441/2/3 | Website - www.isquareit.edu.in | Email - info@isquareit.edu.in
International Institute of Information Technology, I²IT, P-14, Rajiv Gandhi Infotech Park, Hinjawadi Phase 1, Pune - 411 057
Phone - +91 20 22933441/2/3 | Website - www.isquareit.edu.in | Email - info@isquareit.edu.in
E-mail: manjushaa@isquareit.edu.in
Website: http://www.isquareit.edu.in/
Thank You

More Related Content

What's hot (20)

PPTX
Machine Learning: Bias and Variance Trade-off
International Institute of Information Technology (I²IT)
 
PPTX
Engineering Mathematics & Probability Distributions
International Institute of Information Technology (I²IT)
 
PPTX
DAA Introduction to Algorithms & Application
International Institute of Information Technology (I²IT)
 
PDF
Manufacturing Processes - Forging
International Institute of Information Technology (I²IT)
 
PPTX
Introduction to Machine: Shaft and Keys
International Institute of Information Technology (I²IT)
 
PPT
Importance of Theory of Computations
International Institute of Information Technology (I²IT)
 
PPTX
Human Computer Interaction - INPUT OUTPUT CHANNELS
International Institute of Information Technology (I²IT)
 
PPTX
Superstructure and it's various components
International Institute of Information Technology (I²IT)
 
PPTX
Cloud Computing & Virtual Infrastructure
International Institute of Information Technology (I²IT)
 
PPTX
Introduction to Wireless Sensor Networks (WSN)
International Institute of Information Technology (I²IT)
 
PPTX
PIC Microcontroller | ADC Interfacing
International Institute of Information Technology (I²IT)
 
PPTX
DC Circuit - Network, Sources & Law
International Institute of Information Technology (I²IT)
 
PPTX
Difference Between AI(Artificial Intelligence), ML(Machine Learning), DL (Dee...
International Institute of Information Technology (I²IT)
 
PPTX
Artificial Intelligence - Introduction
International Institute of Information Technology (I²IT)
 
PPTX
What are the real differences between a wireframe, storyboard and a prototype?
International Institute of Information Technology (I²IT)
 
Machine Learning: Bias and Variance Trade-off
International Institute of Information Technology (I²IT)
 
Engineering Mathematics & Probability Distributions
International Institute of Information Technology (I²IT)
 
DAA Introduction to Algorithms & Application
International Institute of Information Technology (I²IT)
 
Introduction to Machine: Shaft and Keys
International Institute of Information Technology (I²IT)
 
Importance of Theory of Computations
International Institute of Information Technology (I²IT)
 
Human Computer Interaction - INPUT OUTPUT CHANNELS
International Institute of Information Technology (I²IT)
 
Superstructure and it's various components
International Institute of Information Technology (I²IT)
 
Cloud Computing & Virtual Infrastructure
International Institute of Information Technology (I²IT)
 
Introduction to Wireless Sensor Networks (WSN)
International Institute of Information Technology (I²IT)
 
PIC Microcontroller | ADC Interfacing
International Institute of Information Technology (I²IT)
 
Difference Between AI(Artificial Intelligence), ML(Machine Learning), DL (Dee...
International Institute of Information Technology (I²IT)
 
Artificial Intelligence - Introduction
International Institute of Information Technology (I²IT)
 
What are the real differences between a wireframe, storyboard and a prototype?
International Institute of Information Technology (I²IT)
 

Similar to AVL Tree Explained (20)

PPTX
4. avl
Rajandeep Gill
 
PPTX
Presentation_30219_Content_Document_20250107125144AM.pptx
chiraglab007
 
PDF
Lecture 10 - AVL Trees.pdf
SanghdipUdrake
 
PPT
Presentation1 data structure for CSE.ppt
umakalaimani1
 
PPTX
Fourth Semester BE CSE BCS401 ADA Module 3 PPT.pptx
VENKATESHBHAT25
 
PPTX
AVL Trees.pptx DATA STRUCTURES AND ALGORITHMS
AnyaForger34
 
PPTX
Avl tree
Ajay Singh Rana
 
PPTX
Avl trees final
PRAKASH RANJAN SINGH
 
PPTX
Avl trees
amna izzat
 
PPTX
Lecture 10 data structures and algorithms
Aakash deep Singhal
 
PDF
Avl trees
Xad Kuain
 
PDF
Avl tree detailed
Dr Sandeep Kumar Poonia
 
PPTX
Lecture3
Ali Baba
 
PPTX
Data structures trees and graphs - AVL tree.pptx
MalligaarjunanN
 
PPTX
Adelson velskii Landis rotations based on
banupriyar5
 
PPTX
9.bst(contd.) avl tree
Chandan Singh
 
PPTX
ADSPPT.pptx advanced data structures presentation
YashDubal5
 
PPTX
From_Binary_Trees_to_AVL_Trees_Presentation.pptx
umaranirs
 
PPTX
Avl tree ppt
Surkhab Shelly
 
Presentation_30219_Content_Document_20250107125144AM.pptx
chiraglab007
 
Lecture 10 - AVL Trees.pdf
SanghdipUdrake
 
Presentation1 data structure for CSE.ppt
umakalaimani1
 
Fourth Semester BE CSE BCS401 ADA Module 3 PPT.pptx
VENKATESHBHAT25
 
AVL Trees.pptx DATA STRUCTURES AND ALGORITHMS
AnyaForger34
 
Avl tree
Ajay Singh Rana
 
Avl trees final
PRAKASH RANJAN SINGH
 
Avl trees
amna izzat
 
Lecture 10 data structures and algorithms
Aakash deep Singhal
 
Avl trees
Xad Kuain
 
Avl tree detailed
Dr Sandeep Kumar Poonia
 
Lecture3
Ali Baba
 
Data structures trees and graphs - AVL tree.pptx
MalligaarjunanN
 
Adelson velskii Landis rotations based on
banupriyar5
 
9.bst(contd.) avl tree
Chandan Singh
 
ADSPPT.pptx advanced data structures presentation
YashDubal5
 
From_Binary_Trees_to_AVL_Trees_Presentation.pptx
umaranirs
 
Avl tree ppt
Surkhab Shelly
 
Ad

More from International Institute of Information Technology (I²IT) (20)

PPTX
Understanding Natural Language Processing
International Institute of Information Technology (I²IT)
 
PPTX
Professional Ethics & Etiquette: What Are They & How Do I Get Them?
International Institute of Information Technology (I²IT)
 
PPTX
Writing Skills: Importance of Writing Skills
International Institute of Information Technology (I²IT)
 
PPTX
Professional Communication | Introducing Oneself
International Institute of Information Technology (I²IT)
 
PPTX
Servlet: A Server-side Technology
International Institute of Information Technology (I²IT)
 
PPTX
What Is Jenkins? Features and How It Works
International Institute of Information Technology (I²IT)
 
PPTX
Data Science, Big Data, Data Analytics
International Institute of Information Technology (I²IT)
 
PPTX
Types of Artificial Intelligence
International Institute of Information Technology (I²IT)
 
PPTX
Sentiment Analysis in Machine Learning
International Institute of Information Technology (I²IT)
 
PPT
Java as Object Oriented Programming Language
International Institute of Information Technology (I²IT)
 
PPTX
What Is High Performance-Computing?
International Institute of Information Technology (I²IT)
 
PPTX
Data Visualization - How to connect Microsoft Forms to Power BI
International Institute of Information Technology (I²IT)
 
PPTX
Yoga To Fight & Win Against COVID-19
International Institute of Information Technology (I²IT)
 
Understanding Natural Language Processing
International Institute of Information Technology (I²IT)
 
Professional Ethics & Etiquette: What Are They & How Do I Get Them?
International Institute of Information Technology (I²IT)
 
Writing Skills: Importance of Writing Skills
International Institute of Information Technology (I²IT)
 
Professional Communication | Introducing Oneself
International Institute of Information Technology (I²IT)
 
What Is Jenkins? Features and How It Works
International Institute of Information Technology (I²IT)
 
Data Science, Big Data, Data Analytics
International Institute of Information Technology (I²IT)
 
Sentiment Analysis in Machine Learning
International Institute of Information Technology (I²IT)
 
Java as Object Oriented Programming Language
International Institute of Information Technology (I²IT)
 
Data Visualization - How to connect Microsoft Forms to Power BI
International Institute of Information Technology (I²IT)
 
Yoga To Fight & Win Against COVID-19
International Institute of Information Technology (I²IT)
 
Ad

Recently uploaded (20)

PDF
TrustArc Webinar - Data Privacy Trends 2025: Mid-Year Insights & Program Stra...
TrustArc
 
PDF
Empowering Cloud Providers with Apache CloudStack and Stackbill
ShapeBlue
 
PDF
CloudStack GPU Integration - Rohit Yadav
ShapeBlue
 
PDF
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
PDF
Windsurf Meetup Ottawa 2025-07-12 - Planning Mode at Reliza.pdf
Pavel Shukhman
 
PPTX
Building and Operating a Private Cloud with CloudStack and LINBIT CloudStack ...
ShapeBlue
 
PPTX
Darren Mills The Migration Modernization Balancing Act: Navigating Risks and...
AWS Chicago
 
PDF
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
PDF
Apache CloudStack 201: Let's Design & Build an IaaS Cloud
ShapeBlue
 
PDF
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
PPTX
Top Managed Service Providers in Los Angeles
Captain IT
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PPT
Interview paper part 3, It is based on Interview Prep
SoumyadeepGhosh39
 
PDF
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
PDF
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
PDF
Complete JavaScript Notes: From Basics to Advanced Concepts.pdf
haydendavispro
 
PPTX
✨Unleashing Collaboration: Salesforce Channels & Community Power in Patna!✨
SanjeetMishra29
 
PDF
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
PDF
Meetup Kickoff & Welcome - Rohit Yadav, CSIUG Chairman
ShapeBlue
 
PDF
Français Patch Tuesday - Juillet
Ivanti
 
TrustArc Webinar - Data Privacy Trends 2025: Mid-Year Insights & Program Stra...
TrustArc
 
Empowering Cloud Providers with Apache CloudStack and Stackbill
ShapeBlue
 
CloudStack GPU Integration - Rohit Yadav
ShapeBlue
 
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
Windsurf Meetup Ottawa 2025-07-12 - Planning Mode at Reliza.pdf
Pavel Shukhman
 
Building and Operating a Private Cloud with CloudStack and LINBIT CloudStack ...
ShapeBlue
 
Darren Mills The Migration Modernization Balancing Act: Navigating Risks and...
AWS Chicago
 
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
Apache CloudStack 201: Let's Design & Build an IaaS Cloud
ShapeBlue
 
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
Top Managed Service Providers in Los Angeles
Captain IT
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
Interview paper part 3, It is based on Interview Prep
SoumyadeepGhosh39
 
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
Complete JavaScript Notes: From Basics to Advanced Concepts.pdf
haydendavispro
 
✨Unleashing Collaboration: Salesforce Channels & Community Power in Patna!✨
SanjeetMishra29
 
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
Meetup Kickoff & Welcome - Rohit Yadav, CSIUG Chairman
ShapeBlue
 
Français Patch Tuesday - Juillet
Ivanti
 

AVL Tree Explained

  • 1. AVL TREE Prof. Manjusha Amritkar Information Technology Department International Institute of Information Technology, I²IT www.isquareit.edu.in
  • 2. Binary Search Tree • E.g. 2,4,6,8,10 • Right skewed tree • Time needed to perform insertion ,deletion and many other operations is O(N) in worst case. • We need tree with small height with Log N • Such trees are called as Balanced Binary Search Tree • e.g AVL tree, Red Black Tree International Institute of Information Technology, I²IT, P-14, Rajiv Gandhi Infotech Park, Hinjawadi Phase 1, Pune - 411 057 Phone - +91 20 22933441/2/3 | Website - www.isquareit.edu.in | Email - [email protected] 2 4 6 8 10
  • 3. AVL Tree • AVL tree Named after their inventor Adelson, Velski & Landis, is a self-balancing Binary Search Tree (BST) where the difference between heights of left and right subtrees cannot be more than one for all nodes. • The difference between the heights is called as balanced factor (BF) • BF = height (left subtree) – height (right subtree) • The tree is balanced when BF is -1, 0, 1 International Institute of Information Technology, I²IT, P-14, Rajiv Gandhi Infotech Park, Hinjawadi Phase 1, Pune - 411 057 Phone - +91 20 22933441/2/3 | Website - www.isquareit.edu.in | Email - [email protected]
  • 4. AVL Tree Rotations • If the difference is more than one then the tree is to be balanced using rotations. • Left rotation (LL) Right rotation (RR) Left-Right rotation (LR) Right-Left rotation (RL) International Institute of Information Technology, I²IT, P-14, Rajiv Gandhi Infotech Park, Hinjawadi Phase 1, Pune - 411 057 Phone - +91 20 22933441/2/3 | Website - www.isquareit.edu.in | Email - [email protected]
  • 5. Left Rotation • If a tree becomes unbalanced, when a node is inserted into the right subtree of the right subtree, then we perform a single left rotation International Institute of Information Technology, I²IT, P-14, Rajiv Gandhi Infotech Park, Hinjawadi Phase 1, Pune - 411 057 Phone - +91 20 22933441/2/3 | Website - www.isquareit.edu.in | Email - [email protected]
  • 6. Right Rotation • AVL tree may become unbalanced, if a node is inserted in the left subtree of the left subtree. The tree then needs a right rotation International Institute of Information Technology, I²IT, P-14, Rajiv Gandhi Infotech Park, Hinjawadi Phase 1, Pune - 411 057 Phone - +91 20 22933441/2/3 | Website - www.isquareit.edu.in | Email - [email protected]
  • 7. Left Right Rotations • A node has been inserted into the right subtree of the left subtree. This makes C an unbalanced node. These scenarios cause AVL tree to perform left-right rotation. International Institute of Information Technology, I²IT, P-14, Rajiv Gandhi Infotech Park, Hinjawadi Phase 1, Pune - 411 057 Phone - +91 20 22933441/2/3 | Website - www.isquareit.edu.in | Email - [email protected] LR Rotation
  • 8. Right Left Rotations • A node has been inserted into the left subtree of the right subtree. This makes A, an unbalanced node with balance factor 2. International Institute of Information Technology, I²IT, P-14, Rajiv Gandhi Infotech Park, Hinjawadi Phase 1, Pune - 411 057 Phone - +91 20 22933441/2/3 | Website - www.isquareit.edu.in | Email - [email protected] RL Rotation
  • 9. Example: Construct an AVL Tree by inserting numbers from 1 to 8. International Institute of Information Technology, I²IT, P-14, Rajiv Gandhi Infotech Park, Hinjawadi Phase 1, Pune - 411 057 Phone - +91 20 22933441/2/3 | Website - www.isquareit.edu.in | Email - [email protected]
  • 10. Example: Construct an AVL Tree by inserting numbers from 1 to 8. International Institute of Information Technology, I²IT, P-14, Rajiv Gandhi Infotech Park, Hinjawadi Phase 1, Pune - 411 057 Phone - +91 20 22933441/2/3 | Website - www.isquareit.edu.in | Email - [email protected]
  • 11. Example: Construct an AVL Tree by inserting numbers from 1 to 8. International Institute of Information Technology, I²IT, P-14, Rajiv Gandhi Infotech Park, Hinjawadi Phase 1, Pune - 411 057 Phone - +91 20 22933441/2/3 | Website - www.isquareit.edu.in | Email - [email protected]
  • 12. Example: Construct an AVL Tree by inserting numbers from 1 to 8. International Institute of Information Technology, I²IT, P-14, Rajiv Gandhi Infotech Park, Hinjawadi Phase 1, Pune - 411 057 Phone - +91 20 22933441/2/3 | Website - www.isquareit.edu.in | Email - [email protected]
  • 13. Example: Construct an AVL Tree by inserting numbers from 1 to 8. International Institute of Information Technology, I²IT, P-14, Rajiv Gandhi Infotech Park, Hinjawadi Phase 1, Pune - 411 057 Phone - +91 20 22933441/2/3 | Website - www.isquareit.edu.in | Email - [email protected]
  • 14. Example: Construct an AVL Tree by inserting numbers from 1 to 8. International Institute of Information Technology, I²IT, P-14, Rajiv Gandhi Infotech Park, Hinjawadi Phase 1, Pune - 411 057 Phone - +91 20 22933441/2/3 | Website - www.isquareit.edu.in | Email - [email protected]
  • 15. Example: Construct an AVL Tree by inserting numbers from 50,25,10,5,7,3,30,20,8,15. • Insert 50 • Insert 25 50 0 Tree is balanced 50 1 Tree is balanced 25 0 International Institute of Information Technology, I²IT, P-14, Rajiv Gandhi Infotech Park, Hinjawadi Phase 1, Pune - 411 057 Phone - +91 20 22933441/2/3 | Website - www.isquareit.edu.in | Email - [email protected]
  • 16. Example: Construct an AVL Tree by inserting numbers from 50,25,10,5,7,3,30,20,8,15. • Insert 10 Tree is imbalanced Tree is balanced International Institute of Information Technology, I²IT, P-14, Rajiv Gandhi Infotech Park, Hinjawadi Phase 1, Pune - 411 057 Phone - +91 20 22933441/2/3 | Website - www.isquareit.edu.in | Email - [email protected] 50 2 25 1 10 0 25 1 10 0 50 0 RR Rotation
  • 17. Example: Construct an AVL Tree by inserting numbers from 50,25,10,5,7,3,30,20,8,15. • Insert 5 insert 7 Tree is balanced Tree is imbalanced 25 1 10 1 50 0 5 0 25 1 7 0 50 0 5 0 10 0 Tree is balanced International Institute of Information Technology, I²IT, P-14, Rajiv Gandhi Infotech Park, Hinjawadi Phase 1, Pune - 411 057 Phone - +91 20 22933441/2/3 | Website - www.isquareit.edu.in | Email - [email protected] 25 2 10 2 50 0 5 -1 7 0 LR Rotation
  • 18. Example: Construct an AVL Tree by inserting numbers from 50,25,10,5,7,3,30,20,8,15. Tree is imbalanced 25 2 7 1 50 0 5 1 7 0 5 25 0 3 0 0 Tree is balanced 10 0 3 0 50 0 1 10 International Institute of Information Technology, I²IT, P-14, Rajiv Gandhi Infotech Park, Hinjawadi Phase 1, Pune - 411 057 Phone - +91 20 22933441/2/3 | Website - www.isquareit.edu.in | Email - [email protected] • Insert 3 LL Rotation
  • 19. Example: Construct an AVL Tree by inserting numbers from 50,25,10,5,7,3,30,20,8,15. • Insert 30 insert 20 Tree is imbalanced Tree is balanced 7 -1 5 25 -1 3 0 0 50 1 1 10 0 30 20 0 10 0 7 25 0 5 1 1 50 0 1 0 30 50 0 8 15 0 0 3 0 International Institute of Information Technology, I²IT, P-14, Rajiv Gandhi Infotech Park, Hinjawadi Phase 1, Pune - 411 057 Phone - +91 20 22933441/2/3 | Website - www.isquareit.edu.in | Email - [email protected] 7 -2 5 25 1 3 0 -1 50 1 1 10 30 1 20 15 8 RL Rotation
  • 20. References • http://www.btechsmartclass.com/data_structures/avl-trees.html International Institute of Information Technology, I²IT, P-14, Rajiv Gandhi Infotech Park, Hinjawadi Phase 1, Pune - 411 057 Phone - +91 20 22933441/2/3 | Website - www.isquareit.edu.in | Email - [email protected]
  • 21. International Institute of Information Technology, I²IT, P-14, Rajiv Gandhi Infotech Park, Hinjawadi Phase 1, Pune - 411 057 Phone - +91 20 22933441/2/3 | Website - www.isquareit.edu.in | Email - [email protected] E-mail: [email protected] Website: http://www.isquareit.edu.in/ Thank You