SlideShare a Scribd company logo
1 of 10
DATA STRUCTURES
AVL TRESS
B.ABINAYA BHARATHI M.Sc[Cs&IT]
NADAR SARASWATHI COLLEGE OF ARTS AND SCIENCE
THENI
1
AVL TREES
 AVL tree is a self-balancing Binary Search Tree
 AVL tree balances itself by making rotations when the tree
becomes unbalanced.
 when inserting a element in binary search tree ,The tree
becomes a gigantic line.
 if the size of the tree is n elements,
 performing each insertion takes n operations.
 Performing all n insertions takes roughly n2
operations. 2
BALANCE FACTOR
 In a binary tree the balance factor of a node N is
used
 Balance Factor(N) = Height( RightSubtree(N) ) –
Height( LeftSubtree(N) )
 Balance Factor(N) ∈ {–1,0,+1}
3
ROTATION
 To balance itself, an AVL tree may perform the following four
kinds of rotations −
 Left rotation
 Right rotation
 Left-Right rotation
 Right-Left rotation
 The first two rotations are single rotations
 The next two rotations are double rotations. 4
ROTATIONS IN AVL TREES
5
LEFT ROTATION
 In LL Rotation every node moves one position to left from the
current position.
6
RIGHT RIGHT ROTATION
o In RR Rotation every node moves one position to right from
the current position.
7
LEFT RIGHT ROTATION
o The LR Rotation is combination of single left rotation
followed by single right rotation.
o In LR Rotation, first every node moves one position to left
then one position to right from the current position.
8
RIGHT LEFT ROTATION
oThe RL Rotation is combination of single right rotation
followed by single left rotation.
oIn RL Rotation, first every node moves one position to right
then one position to left from the current position.
9
THANK YOU
10

More Related Content

Similar to data structures

Adelson velskii Landis rotations based on
Adelson velskii Landis rotations based onAdelson velskii Landis rotations based on
Adelson velskii Landis rotations based on
banupriyar5
 
Avl tree
Avl treeAvl tree
Avl tree
Van Pham
 

Similar to data structures (20)

Adelson velskii Landis rotations based on
Adelson velskii Landis rotations based onAdelson velskii Landis rotations based on
Adelson velskii Landis rotations based on
 
Avl trees
Avl treesAvl trees
Avl trees
 
Avl tree
Avl treeAvl tree
Avl tree
 
AVL tree ( Balanced Binary Search Tree)-Data Structure
AVL tree ( Balanced Binary Search Tree)-Data StructureAVL tree ( Balanced Binary Search Tree)-Data Structure
AVL tree ( Balanced Binary Search Tree)-Data Structure
 
AVL Tree.pptx
AVL Tree.pptxAVL Tree.pptx
AVL Tree.pptx
 
Avl tree
Avl treeAvl tree
Avl tree
 
Avl trees 2
Avl trees 2Avl trees 2
Avl trees 2
 
AVL Tree
AVL TreeAVL Tree
AVL Tree
 
3-avl-tree.ppt
3-avl-tree.ppt3-avl-tree.ppt
3-avl-tree.ppt
 
AVL Tree
AVL TreeAVL Tree
AVL Tree
 
DS_Mod4_2.pdf
DS_Mod4_2.pdfDS_Mod4_2.pdf
DS_Mod4_2.pdf
 
Data Structure and Algorithms AVL Trees
Data Structure and Algorithms AVL TreesData Structure and Algorithms AVL Trees
Data Structure and Algorithms AVL Trees
 
Avl trees final
Avl trees finalAvl trees final
Avl trees final
 
Avl tree ppt
Avl tree pptAvl tree ppt
Avl tree ppt
 
Avl tree
Avl treeAvl tree
Avl tree
 
Avl tree
Avl treeAvl tree
Avl tree
 
4. avl
4. avl4. avl
4. avl
 
AVL Tree Data Structure
AVL Tree Data StructureAVL Tree Data Structure
AVL Tree Data Structure
 
Ie
IeIe
Ie
 
C++ UNIT4.pptx
C++ UNIT4.pptxC++ UNIT4.pptx
C++ UNIT4.pptx
 

More from Abinaya B

More from Abinaya B (18)

Multimedia
MultimediaMultimedia
Multimedia
 
Overview of bigdata
Overview of bigdataOverview of bigdata
Overview of bigdata
 
exception handling in java
exception handling in javaexception handling in java
exception handling in java
 
graphics programming in java
graphics programming in javagraphics programming in java
graphics programming in java
 
data structures- back tracking
data structures- back trackingdata structures- back tracking
data structures- back tracking
 
exception handling in java
exception handling in javaexception handling in java
exception handling in java
 
digital image processing
digital image processingdigital image processing
digital image processing
 
Image filtering in Digital image processing
Image filtering in Digital image processingImage filtering in Digital image processing
Image filtering in Digital image processing
 
software engineering
software engineeringsoftware engineering
software engineering
 
software cost factor
software cost factorsoftware cost factor
software cost factor
 
Data Mining
Data MiningData Mining
Data Mining
 
Datamining
DataminingDatamining
Datamining
 
Basic topic on os
Basic topic on osBasic topic on os
Basic topic on os
 
Digital principles basic
Digital principles basicDigital principles basic
Digital principles basic
 
Rdbms1
Rdbms1Rdbms1
Rdbms1
 
Managing I/O & String function in C
Managing I/O & String function in CManaging I/O & String function in C
Managing I/O & String function in C
 
Introduction to 80386
Introduction to 80386Introduction to 80386
Introduction to 80386
 
Network standardization
Network standardizationNetwork standardization
Network standardization
 

Recently uploaded

Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
negromaestrong
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
heathfieldcps1
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
PECB
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
kauryashika82
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
Chris Hunter
 

Recently uploaded (20)

Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural ResourcesEnergy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 

data structures

  • 1. DATA STRUCTURES AVL TRESS B.ABINAYA BHARATHI M.Sc[Cs&IT] NADAR SARASWATHI COLLEGE OF ARTS AND SCIENCE THENI 1
  • 2. AVL TREES  AVL tree is a self-balancing Binary Search Tree  AVL tree balances itself by making rotations when the tree becomes unbalanced.  when inserting a element in binary search tree ,The tree becomes a gigantic line.  if the size of the tree is n elements,  performing each insertion takes n operations.  Performing all n insertions takes roughly n2 operations. 2
  • 3. BALANCE FACTOR  In a binary tree the balance factor of a node N is used  Balance Factor(N) = Height( RightSubtree(N) ) – Height( LeftSubtree(N) )  Balance Factor(N) ∈ {–1,0,+1} 3
  • 4. ROTATION  To balance itself, an AVL tree may perform the following four kinds of rotations −  Left rotation  Right rotation  Left-Right rotation  Right-Left rotation  The first two rotations are single rotations  The next two rotations are double rotations. 4
  • 6. LEFT ROTATION  In LL Rotation every node moves one position to left from the current position. 6
  • 7. RIGHT RIGHT ROTATION o In RR Rotation every node moves one position to right from the current position. 7
  • 8. LEFT RIGHT ROTATION o The LR Rotation is combination of single left rotation followed by single right rotation. o In LR Rotation, first every node moves one position to left then one position to right from the current position. 8
  • 9. RIGHT LEFT ROTATION oThe RL Rotation is combination of single right rotation followed by single left rotation. oIn RL Rotation, first every node moves one position to right then one position to left from the current position. 9