SlideShare une entreprise Scribd logo
1  sur  11
Télécharger pour lire hors ligne
AVL Tree
ID no:-170413107013
Name:-Yaksh Jethva
Content
➔ About AVL Tree
➔ Operation Performed on AVL Tree
◆ Searching
◆ Traverse
◆ Insertion
◆ Deletion
➔ AVL Rotation
◆ Left Rotation
◆ Right Rotation
◆ Left-Right Rotation
◆ Right-Left Rotation
About AVL tree
➢ An AVL tree is a self-balancing binary search tree. It was the first
such data structure to be invented. In an AVL tree, the heights of
the two child subtrees of any node differ by at most one; if at any
time they differ by more than one, rebalancing is done to restore
this property.
➢ The AVL tree is named after its two Soviet inventors, Georgy
Adelson-Velsky and Evgenii Landis, who published it in their 1962
paper "An algorithm for the organization of information".
Operations
Searching
Searching for a specific key in an AVL tree can be done the same way as
that of a normal unbalanced binary search tree. The number of
comparisons required for successful search is limited by the height h and
for unsuccessful search is very close to h, so both are in O(log n).
Traversal
Traversal term refers to the process of visiting (checking and/or
updating) each node in a tree data structure exactly once.
Operation
Insertion
When inserting an element into an AVL tree, you initially follow the same process as
inserting into a Binary Search Tree. More explicitly: In case a preceding search has
not been successful the search routine returns the tree itself with indication
EMPTY and the new node is inserted as root. Or, if the tree has not been empty the
search routine returns a node and a direction (left or right) where the returned
node does not have a child. Then the node to be inserted is made child of the
returned node at the returned direction.
Deletion
The preliminary steps for deleting a node are described in section Binary search
tree. There, the effective deletion of the subject node or the replacement node
decreases the height of the corresponding child tree either from 1 to 0 or from 2
to 1, if that node had a child.
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.
As depicted, the unbalanced node becomes the right child of its left child by
performing a right rotation.
AVL 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 and the next two rotations are
double rotations. To have an unbalanced tree, we at least need a tree of
height 2. With this simple tree, let's understand them one by one.
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 −
In our example, node A has become unbalanced as a node is inserted in the right
subtree of A's right subtree. We perform the left rotation by making A the
left-subtree of B.
Left-Right Rotation
Double rotations are slightly complex version of already explained versions of rotations. To
understand them better, we should take note of each action performed while rotation. Let's first
check how to perform Left-Right rotation. A left-right rotation is a combination of left rotation
followed by right rotation.
Right-Left Rotation
The second type of double rotation is Right-Left Rotation. It is a combination of
right rotation followed by left rotation.
Thank YOu!!!

Contenu connexe

Tendances

Tendances (20)

Avl trees
Avl treesAvl trees
Avl trees
 
1.7 avl tree
1.7 avl tree 1.7 avl tree
1.7 avl tree
 
Data Structure and Algorithms AVL Trees
Data Structure and Algorithms AVL TreesData Structure and Algorithms AVL Trees
Data Structure and Algorithms AVL Trees
 
Bst(Binary Search Tree)
Bst(Binary Search Tree)Bst(Binary Search Tree)
Bst(Binary Search Tree)
 
1.1 binary tree
1.1 binary tree1.1 binary tree
1.1 binary tree
 
Binary search tree operations
Binary search tree operationsBinary search tree operations
Binary search tree operations
 
Threaded Binary Tree.pptx
Threaded Binary Tree.pptxThreaded Binary Tree.pptx
Threaded Binary Tree.pptx
 
Searching techniques in Data Structure And Algorithm
Searching techniques in Data Structure And AlgorithmSearching techniques in Data Structure And Algorithm
Searching techniques in Data Structure And Algorithm
 
Doubly Linked List
Doubly Linked ListDoubly Linked List
Doubly Linked List
 
Singly link list
Singly link listSingly link list
Singly link list
 
AVL Tree
AVL TreeAVL Tree
AVL Tree
 
Binary tree
Binary  treeBinary  tree
Binary tree
 
Binary trees1
Binary trees1Binary trees1
Binary trees1
 
trees in data structure
trees in data structure trees in data structure
trees in data structure
 
Data Structure (Tree)
Data Structure (Tree)Data Structure (Tree)
Data Structure (Tree)
 
Expression trees
Expression treesExpression trees
Expression trees
 
Queue
QueueQueue
Queue
 
Tree
TreeTree
Tree
 
Binary search tree(bst)
Binary search tree(bst)Binary search tree(bst)
Binary search tree(bst)
 
BINARY TREE REPRESENTATION.ppt
BINARY TREE REPRESENTATION.pptBINARY TREE REPRESENTATION.ppt
BINARY TREE REPRESENTATION.ppt
 

Similaire à AVL tree ( Balanced Binary Search Tree)-Data Structure

Avl tree tutorial
Avl tree tutorialAvl tree tutorial
Avl tree tutorial
Ravi Kumar
 
Adelson velskii Landis rotations based on
Adelson velskii Landis rotations based onAdelson velskii Landis rotations based on
Adelson velskii Landis rotations based on
banupriyar5
 

Similaire à AVL tree ( Balanced Binary Search Tree)-Data Structure (20)

Avl tree algorithm
Avl tree algorithmAvl tree algorithm
Avl tree algorithm
 
AVL tree PPT.pptx
AVL tree PPT.pptxAVL tree PPT.pptx
AVL tree PPT.pptx
 
3-avl-tree.ppt
3-avl-tree.ppt3-avl-tree.ppt
3-avl-tree.ppt
 
AVL Tree.pptx
AVL Tree.pptxAVL Tree.pptx
AVL Tree.pptx
 
Study about AVL Tree & Operations
Study about AVL Tree & OperationsStudy about AVL Tree & Operations
Study about AVL Tree & Operations
 
Avl tree ppt
Avl tree pptAvl tree ppt
Avl tree ppt
 
Avl trees final
Avl trees finalAvl trees final
Avl trees final
 
C++ UNIT4.pptx
C++ UNIT4.pptxC++ UNIT4.pptx
C++ UNIT4.pptx
 
AVL Tree
AVL TreeAVL Tree
AVL Tree
 
AVL_Trees using DSA concepts and how to do
AVL_Trees using DSA concepts and how to doAVL_Trees using DSA concepts and how to do
AVL_Trees using DSA concepts and how to do
 
Avl tree
Avl treeAvl tree
Avl tree
 
Avl tree-rotations
Avl tree-rotationsAvl tree-rotations
Avl tree-rotations
 
Avl tree
Avl treeAvl tree
Avl tree
 
Avl tree tutorial
Avl tree tutorialAvl tree tutorial
Avl tree tutorial
 
Data structures trees and graphs - AVL tree.pptx
Data structures trees and graphs - AVL  tree.pptxData structures trees and graphs - AVL  tree.pptx
Data structures trees and graphs - AVL tree.pptx
 
Adelson velskii Landis rotations based on
Adelson velskii Landis rotations based onAdelson velskii Landis rotations based on
Adelson velskii Landis rotations based on
 
data structures
data structuresdata structures
data structures
 
Avltrees
AvltreesAvltrees
Avltrees
 
DS_Mod4_2.pdf
DS_Mod4_2.pdfDS_Mod4_2.pdf
DS_Mod4_2.pdf
 
Avl trees 2
Avl trees 2Avl trees 2
Avl trees 2
 

Plus de Yaksh Jethva

Plus de Yaksh Jethva (7)

Operator_Overloaing_Type_Conversion_OOPC(C++)
Operator_Overloaing_Type_Conversion_OOPC(C++)Operator_Overloaing_Type_Conversion_OOPC(C++)
Operator_Overloaing_Type_Conversion_OOPC(C++)
 
About Markets (Types of markets) - Economics
About Markets (Types of markets) - EconomicsAbout Markets (Types of markets) - Economics
About Markets (Types of markets) - Economics
 
Cost and Various Cost Types
Cost and Various Cost TypesCost and Various Cost Types
Cost and Various Cost Types
 
Logic Families ( Digital Electronics )
Logic Families ( Digital Electronics )Logic Families ( Digital Electronics )
Logic Families ( Digital Electronics )
 
ANSI-SPARC Architecture - (3-Tier Architecture)
ANSI-SPARC Architecture - (3-Tier Architecture)ANSI-SPARC Architecture - (3-Tier Architecture)
ANSI-SPARC Architecture - (3-Tier Architecture)
 
Transaction Properties(ACID Properties)
Transaction Properties(ACID Properties)Transaction Properties(ACID Properties)
Transaction Properties(ACID Properties)
 
STACK ( LIFO STRUCTURE) - Data Structure
STACK ( LIFO STRUCTURE) - Data StructureSTACK ( LIFO STRUCTURE) - Data Structure
STACK ( LIFO STRUCTURE) - Data Structure
 

Dernier

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
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
QucHHunhnh
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch Letter
MateoGardella
 
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
 

Dernier (20)

fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
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
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
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
 
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...
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch Letter
 
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
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.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
 
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
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .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.
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 

AVL tree ( Balanced Binary Search Tree)-Data Structure

  • 2. Content ➔ About AVL Tree ➔ Operation Performed on AVL Tree ◆ Searching ◆ Traverse ◆ Insertion ◆ Deletion ➔ AVL Rotation ◆ Left Rotation ◆ Right Rotation ◆ Left-Right Rotation ◆ Right-Left Rotation
  • 3. About AVL tree ➢ An AVL tree is a self-balancing binary search tree. It was the first such data structure to be invented. In an AVL tree, the heights of the two child subtrees of any node differ by at most one; if at any time they differ by more than one, rebalancing is done to restore this property. ➢ The AVL tree is named after its two Soviet inventors, Georgy Adelson-Velsky and Evgenii Landis, who published it in their 1962 paper "An algorithm for the organization of information".
  • 4. Operations Searching Searching for a specific key in an AVL tree can be done the same way as that of a normal unbalanced binary search tree. The number of comparisons required for successful search is limited by the height h and for unsuccessful search is very close to h, so both are in O(log n). Traversal Traversal term refers to the process of visiting (checking and/or updating) each node in a tree data structure exactly once.
  • 5. Operation Insertion When inserting an element into an AVL tree, you initially follow the same process as inserting into a Binary Search Tree. More explicitly: In case a preceding search has not been successful the search routine returns the tree itself with indication EMPTY and the new node is inserted as root. Or, if the tree has not been empty the search routine returns a node and a direction (left or right) where the returned node does not have a child. Then the node to be inserted is made child of the returned node at the returned direction. Deletion The preliminary steps for deleting a node are described in section Binary search tree. There, the effective deletion of the subject node or the replacement node decreases the height of the corresponding child tree either from 1 to 0 or from 2 to 1, if that node had a child.
  • 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. As depicted, the unbalanced node becomes the right child of its left child by performing a right rotation.
  • 7. AVL 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 and the next two rotations are double rotations. To have an unbalanced tree, we at least need a tree of height 2. With this simple tree, let's understand them one by one.
  • 8. 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 − In our example, node A has become unbalanced as a node is inserted in the right subtree of A's right subtree. We perform the left rotation by making A the left-subtree of B.
  • 9. Left-Right Rotation Double rotations are slightly complex version of already explained versions of rotations. To understand them better, we should take note of each action performed while rotation. Let's first check how to perform Left-Right rotation. A left-right rotation is a combination of left rotation followed by right rotation.
  • 10. Right-Left Rotation The second type of double rotation is Right-Left Rotation. It is a combination of right rotation followed by left rotation.