SlideShare a Scribd company logo
1 of 12
Data Structure & Files
Unit 5: Advance Tree
AVL Tree
Ms. Vrushali Dhanokar (M.Tech CSE)
Assistant Professor
IT Department
dhanokarvrushali@gmail.com
Why AVL Tree?
Example: Keys are: 1, 2, 3, 4, 5, 6, 7. Generate Binary Tree.
• Fig 1: AVL Tree
• Fig 2. Binary Tree
• Insert 8 in BT: 7 comparisons.
• Insert 8 in AVL: 3 comparisons.
So, AVL Tree:
• Height balance trees.
• Insertion and deletion have low
time complexity.
What is AVL Tree?
• AVL invented by G.M. Adelson-Velsky and E.M. Landis. So, name is AVL.
• AVL tree is a height-balanced binary search tree.
• AVL tree, balance factor of every node is either -1, 0 or +1.
• Every node maintains an extra information known as balance factor.
• Balance factor = heightOfLeftSubtree – heightOfRightSubtree.
• Every AVL Tree is a binary search tree but every Binary Search Tree need not be AVL tree.
• Operation perform Search, Insertion, Deletion with O(log n) time complexity.
AVL Tree Rotations:
Type 1: RR Relationship (Left Rotation):
Type 2: LL Relationship (Right Rotation)
AVL Tree Rotations:
Type 3: LR Relationship (First Left Rotation then Right Rotation)
Type 4: RL Relationship (First Right Rotation then Left Rotation)
Insertion Operations In AVL Tree
In AVL Tree, a new node is always inserted as a leaf node.
Step 1 - Insert the new element into the tree using Binary Search Tree insertion logic.
Step 2 - After insertion, check the Balance Factor of every node.
Step 3 - If the Balance Factor of every node is 0 or 1 or -1 then go for next operation.
Step 4 - If the Balance Factor of any node is other than 0 or 1 or -1 then that tree is said to
be imbalanced. In this case, perform suitable Rotation to make it balanced and go for
next operation.
Example of Insertion Operation in AVL Tree
Que. Construct AVL Tree by inserting number from 1 to 8.
Continue..
Continue..
Difference Between Red Black Tree & AVL Tree
Important Questions
By SPPU Exam Pattern
1. Define Balance Factor of a node in a Binary Tree. 2M
2. What are the benefits of AVL Tree over BST? 4M
3. Explain Insertion operation in AVL tree with suitable example. 5M
4. Obtain AVL tree of following data element
50,55,60,15,10,40,20,45,30,70,80. 8M
5. Build AVL Tree of Sun, Fri, Mon, Wed, Tue, Thurs, Sat. 8M
6. Build AVL Tree of A,Z,B,Y,C,X,D,U. 8M
7. Build AVL Tree of MAR,MAY,NOV,AUG,APR,JAN,DEC,JUL. 8M
(Use lexicographic order i.e April ……. Sept)
8. Difference Between Red Black Tree & AVL Tree. 6M
Thank You….!

More Related Content

What's hot (20)

Tree - Data Structure
Tree - Data StructureTree - Data Structure
Tree - Data Structure
 
Threaded Binary Tree.pptx
Threaded Binary Tree.pptxThreaded Binary Tree.pptx
Threaded Binary Tree.pptx
 
Tree Traversal
Tree TraversalTree Traversal
Tree Traversal
 
Expression trees
Expression treesExpression trees
Expression trees
 
Red black tree
Red black treeRed black tree
Red black tree
 
Stacks IN DATA STRUCTURES
Stacks IN DATA STRUCTURESStacks IN DATA STRUCTURES
Stacks IN DATA STRUCTURES
 
Doubly Linked List
Doubly Linked ListDoubly Linked List
Doubly Linked List
 
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
 
1.1 binary tree
1.1 binary tree1.1 binary tree
1.1 binary tree
 
Circular link list.ppt
Circular link list.pptCircular link list.ppt
Circular link list.ppt
 
BINARY TREE REPRESENTATION.ppt
BINARY TREE REPRESENTATION.pptBINARY TREE REPRESENTATION.ppt
BINARY TREE REPRESENTATION.ppt
 
Avl trees
Avl treesAvl trees
Avl trees
 
Trees, Binary Search Tree, AVL Tree in Data Structures
Trees, Binary Search Tree, AVL Tree in Data Structures Trees, Binary Search Tree, AVL Tree in Data Structures
Trees, Binary Search Tree, AVL Tree in Data Structures
 
Binary tree
Binary  treeBinary  tree
Binary tree
 
Binary search tree(bst)
Binary search tree(bst)Binary search tree(bst)
Binary search tree(bst)
 
Queue ppt
Queue pptQueue ppt
Queue ppt
 
BINARY SEARCH TREE
BINARY SEARCH TREEBINARY SEARCH TREE
BINARY SEARCH TREE
 
Binary Search Tree
Binary Search TreeBinary Search Tree
Binary Search Tree
 
1.5 binary search tree
1.5 binary search tree1.5 binary search tree
1.5 binary search tree
 
Hashing
HashingHashing
Hashing
 

Similar to AVL Tree in Data Structure

AVL Trees.pptx DATA STRUCTURES AND ALGORITHMS
AVL Trees.pptx DATA STRUCTURES AND ALGORITHMSAVL Trees.pptx DATA STRUCTURES AND ALGORITHMS
AVL Trees.pptx DATA STRUCTURES AND ALGORITHMSAnyaForger34
 
Lecture 10 - AVL Trees.pdf
Lecture 10 - AVL Trees.pdfLecture 10 - AVL Trees.pdf
Lecture 10 - AVL Trees.pdfSanghdipUdrake
 
Coding Component (50)Weve provided you with an implementation .docx
Coding Component (50)Weve provided you with an implementation .docxCoding Component (50)Weve provided you with an implementation .docx
Coding Component (50)Weve provided you with an implementation .docxmary772
 
Unit 1_Stack and Queue using Linked Organization.pdf
Unit 1_Stack and Queue using Linked Organization.pdfUnit 1_Stack and Queue using Linked Organization.pdf
Unit 1_Stack and Queue using Linked Organization.pdfKanchanPatil34
 
358 33 powerpoint-slides_11-efficient-binary-trees_chapter-11
358 33 powerpoint-slides_11-efficient-binary-trees_chapter-11358 33 powerpoint-slides_11-efficient-binary-trees_chapter-11
358 33 powerpoint-slides_11-efficient-binary-trees_chapter-11sumitbardhan
 
Assignment Two Objectives • Understand how the.docx
Assignment Two   Objectives • Understand how the.docxAssignment Two   Objectives • Understand how the.docx
Assignment Two Objectives • Understand how the.docxlynettearnold46882
 

Similar to AVL Tree in Data Structure (10)

AVL Trees.pptx DATA STRUCTURES AND ALGORITHMS
AVL Trees.pptx DATA STRUCTURES AND ALGORITHMSAVL Trees.pptx DATA STRUCTURES AND ALGORITHMS
AVL Trees.pptx DATA STRUCTURES AND ALGORITHMS
 
Lecture 10 - AVL Trees.pdf
Lecture 10 - AVL Trees.pdfLecture 10 - AVL Trees.pdf
Lecture 10 - AVL Trees.pdf
 
Coding Component (50)Weve provided you with an implementation .docx
Coding Component (50)Weve provided you with an implementation .docxCoding Component (50)Weve provided you with an implementation .docx
Coding Component (50)Weve provided you with an implementation .docx
 
Binary Search Tree
Binary Search TreeBinary Search Tree
Binary Search Tree
 
Unit 1_Stack and Queue using Linked Organization.pdf
Unit 1_Stack and Queue using Linked Organization.pdfUnit 1_Stack and Queue using Linked Organization.pdf
Unit 1_Stack and Queue using Linked Organization.pdf
 
Segment tree
Segment treeSegment tree
Segment tree
 
358 33 powerpoint-slides_11-efficient-binary-trees_chapter-11
358 33 powerpoint-slides_11-efficient-binary-trees_chapter-11358 33 powerpoint-slides_11-efficient-binary-trees_chapter-11
358 33 powerpoint-slides_11-efficient-binary-trees_chapter-11
 
Linked List vs. AVL Tree in Modulo Ten Search
Linked List vs. AVL Tree in Modulo Ten SearchLinked List vs. AVL Tree in Modulo Ten Search
Linked List vs. AVL Tree in Modulo Ten Search
 
Homework3
Homework3Homework3
Homework3
 
Assignment Two Objectives • Understand how the.docx
Assignment Two   Objectives • Understand how the.docxAssignment Two   Objectives • Understand how the.docx
Assignment Two Objectives • Understand how the.docx
 

Recently uploaded

Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...VICTOR MAESTRE RAMIREZ
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxk795866
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerAnamika Sarkar
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 
Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvLewisJB
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort servicejennyeacort
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfAsst.prof M.Gokilavani
 
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEINFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEroselinkalist12
 
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfCCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfAsst.prof M.Gokilavani
 
Introduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHIntroduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHC Sai Kiran
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptSAURABHKUMAR892774
 
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)dollysharma2066
 
EduAI - E learning Platform integrated with AI
EduAI - E learning Platform integrated with AIEduAI - E learning Platform integrated with AI
EduAI - E learning Platform integrated with AIkoyaldeepu123
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxbritheesh05
 
Churning of Butter, Factors affecting .
Churning of Butter, Factors affecting  .Churning of Butter, Factors affecting  .
Churning of Butter, Factors affecting .Satyam Kumar
 
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)Dr SOUNDIRARAJ N
 

Recently uploaded (20)

young call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Serviceyoung call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Service
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptx
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 
Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvv
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
 
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
 
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEINFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
 
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfCCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
 
Introduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHIntroduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECH
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.ppt
 
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
 
EduAI - E learning Platform integrated with AI
EduAI - E learning Platform integrated with AIEduAI - E learning Platform integrated with AI
EduAI - E learning Platform integrated with AI
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptx
 
Churning of Butter, Factors affecting .
Churning of Butter, Factors affecting  .Churning of Butter, Factors affecting  .
Churning of Butter, Factors affecting .
 
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
 

AVL Tree in Data Structure

  • 1. Data Structure & Files Unit 5: Advance Tree AVL Tree Ms. Vrushali Dhanokar (M.Tech CSE) Assistant Professor IT Department dhanokarvrushali@gmail.com
  • 2. Why AVL Tree? Example: Keys are: 1, 2, 3, 4, 5, 6, 7. Generate Binary Tree. • Fig 1: AVL Tree • Fig 2. Binary Tree • Insert 8 in BT: 7 comparisons. • Insert 8 in AVL: 3 comparisons. So, AVL Tree: • Height balance trees. • Insertion and deletion have low time complexity.
  • 3. What is AVL Tree? • AVL invented by G.M. Adelson-Velsky and E.M. Landis. So, name is AVL. • AVL tree is a height-balanced binary search tree. • AVL tree, balance factor of every node is either -1, 0 or +1. • Every node maintains an extra information known as balance factor. • Balance factor = heightOfLeftSubtree – heightOfRightSubtree. • Every AVL Tree is a binary search tree but every Binary Search Tree need not be AVL tree. • Operation perform Search, Insertion, Deletion with O(log n) time complexity.
  • 4. AVL Tree Rotations: Type 1: RR Relationship (Left Rotation): Type 2: LL Relationship (Right Rotation)
  • 5. AVL Tree Rotations: Type 3: LR Relationship (First Left Rotation then Right Rotation) Type 4: RL Relationship (First Right Rotation then Left Rotation)
  • 6. Insertion Operations In AVL Tree In AVL Tree, a new node is always inserted as a leaf node. Step 1 - Insert the new element into the tree using Binary Search Tree insertion logic. Step 2 - After insertion, check the Balance Factor of every node. Step 3 - If the Balance Factor of every node is 0 or 1 or -1 then go for next operation. Step 4 - If the Balance Factor of any node is other than 0 or 1 or -1 then that tree is said to be imbalanced. In this case, perform suitable Rotation to make it balanced and go for next operation.
  • 7. Example of Insertion Operation in AVL Tree Que. Construct AVL Tree by inserting number from 1 to 8.
  • 10. Difference Between Red Black Tree & AVL Tree
  • 11. Important Questions By SPPU Exam Pattern 1. Define Balance Factor of a node in a Binary Tree. 2M 2. What are the benefits of AVL Tree over BST? 4M 3. Explain Insertion operation in AVL tree with suitable example. 5M 4. Obtain AVL tree of following data element 50,55,60,15,10,40,20,45,30,70,80. 8M 5. Build AVL Tree of Sun, Fri, Mon, Wed, Tue, Thurs, Sat. 8M 6. Build AVL Tree of A,Z,B,Y,C,X,D,U. 8M 7. Build AVL Tree of MAR,MAY,NOV,AUG,APR,JAN,DEC,JUL. 8M (Use lexicographic order i.e April ……. Sept) 8. Difference Between Red Black Tree & AVL Tree. 6M