SlideShare a Scribd company logo
1 of 4
Download to read offline
International Journal of Current Trends in Engineering & Research
e-ISSN 2455–1392 Volume 1 Issue 2, December 2015 pp. 8-11
http://www.ijcter.com
@IJCTER-2015, All rights Reserved 8
Study about AVL Tree & Operations
Viraj Mehta1
, Kapil Prajapati2
1,2
Indira Gandhi National Open University
Abstract—AVL tree is the first dynamic tree in data structure which minimizes its height during
insertion and deletion operations. This is because searching time is directly proportional to the height
of binary search tree (BST). When insertion operation is performed it may result into increasing the
height of the tree and when deletion is performed it may result into decreasing the height. To make
the BST a height balance tree (AVL tree) creators of the AVL tree proposed various rotations. This
paper shows BST and its operation and AVL.
Keyword— AVL, BST
I. INTRODUCTION
A binary search tree is a binary tree with a special property called the BST-property, which is given
as follows:
For all nodes x and y, if y belongs to the left subtree of x, then the key at y is less than the key at x,
and if y belongs to the right subtree of x, then the key at y is greater than the key at x.
We will assume that the keys of a BST are pairwise distinct. Each node has the following attributes:
• p, left, and right, which are pointers to the parent, the left child, and the right child, respectively,
and
• key, which is key stored at the node.
Example:
Figure 1: BST
Traversal of the Nodes in a BST By traversal" we mean visiting all the nodes in a graph. Traversal
strategies can be specied by the ordering of the three objects to visit: the current node, the left
subtree, and the right subtree. We assume the the left subtree always comes before the right subtree.
Then there are three strategies.
1. Inorder. The ordering is: the left subtree,the current node, the right subtree.
2. Preorder. The ordering is: the current node, the left subtree, the right subtree.
International Journal of Current Trends in Engineering & Research (IJCTER)
Volume 01, Issue 02; October– 2015 pp 1-4
@IJCTER-2015, All rights Reserved 9
3. Postorder. The ordering is: the left subtree, the right subtree, the current node.
The AVL tree is named after its two Soviet inventors, Georgy Adelson-Velsky and E.M. Landis,
who published it in their 1962 paper "An algorithm for the organization of information".[1] It take
O(log n) time for the basic operations. We know that every AVL tree is a BST (Binary Search Tree)
while every BST is not an AVL tree.[2] AVL tree is a selfbalancing binary search tree. 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. Insertions and deletions may require
the tree to be rebalanced by one or more tree rotations.
II. OPERATIONS ON AVL TREE
2.1 Searching Searching in an AVL tree is done as in any binary search tree. The special thing about
AVL trees is that the number of comparisons required, i.e. The AVL tree's height, is guaranteed
never to exceed log (n).
2.2 Traversal Once a node has been found in a balanced tree, the next or previous nodes can be
explored in amortized constant time. Some instances of exploring these "nearby" nodes require
traversing up to log(n) links (particularly when moving from the rightmost leaf of the root's left
subtree to the root or from the root to the leftmost leaf of the root's right subtree; in the example
AVL tree, moving from node 14 to the next but one node 19 takes 4 steps). However, exploring all n
nodes of the tree in this manner would use each link exactly twice: one traversal to enter the subtree
rooted at that node, another to leave that node's subtree after having explored it. And since there are
n−1 links in any tree, the amortized cost is found to be 2×(n−1)/n, or approximately 2. After
inserting a node, it is necessary to check each of the node's ancestors for consistency with the rules
of AVL ("retracing"). The balance factor is calculated as follows: balanceFactor = height(left
subtree) -height(right subtree). Since with a single insertion the height of an AVL subtree cannot
increase by more than one, the temporary balance factor of a node will be in the range from −2 to
+2. For each node checked, if the balance factor remains in the range from −1 to +1 then only
corrections of the balance factor, but no rotations are necessary. However, if balance factor becomes
less than −1 or greater than +1, the subtree rooted at this node is unbalanced.[1]
Rotations in Insertion Operation
In case of insertion, we have following rotations.
2.2.1 LL Rotation When a node X is inserted in the left sub tree of left sub tree of node N.
2.2.2 RR Rotation When a node X is inserted in the right sub tree of right sub tree of node N. [2]
Pictorial description of how rotations rebalance an AVL tree. The numbered circles represent the
nodes being rebalanced. The lettered triangles represent subtrees which are themselves balanced
AVL trees. A blue number next to a node denotes possible balance factors (those in parentheses
occurring only in case of deletion). Figure 2
2.3 Deletion Let node X be the node with the value we need to delete, and let node Y be a node in
the tree we need to find to take node X's place, and let node Z be the actual node we take out of the
tree. Deleting a node with two children from a binary search tree using the in-order predecessor
(rightmost node in the left subtree, labelled 6).
International Journal of Current Trends in Engineering & Research (IJCTER)
Volume 01, Issue 02; October– 2015 pp 1-4
@IJCTER-2015, All rights Reserved 10
Figure 2 AVL Tree
Steps to consider when deleting a node in an AVL tree are the following:
1. If node X is a leaf or has only one child, skip to step 5 with Z: =X.
2. Otherwise, determine node Y by finding the largest node in node X's left subtree (the inorder
predecessor of X − it does not have a right child) or the smallest in its right subtree (the in-order
successor of X − it does not have a left child).
3. Exchange all the child and parent links of node X with those of node Y. In this step, the in-order
sequence between nodes X and Y is temporarily disturbed, but the tree structure doesn't change.
4. Choose node Z to be all the child and parentlinks of old node Y = those of new node X.
5. If node Z has a subtree (which then is a leaf) attach it to Z's parent.
6. If node Z was the root (its parent is null), update root.
7. Delete node Z.
International Journal of Current Trends in Engineering & Research (IJCTER)
Volume 01, Issue 02; October– 2015 pp 1-4
@IJCTER-2015, All rights Reserved 11
8. Retrace the path back up the tree (starting with node Z's parent) to the root, adjusting the balance
factors as needed. [1]
Rotations in Deletion Operation In case of deletion, we have following rotations. 2.3.1 Let the
deletion is being performed into right sub tree then we have three types of rotations R(0) rotation
,R(-1) rotation and R(+1) rotation. 2.3.2 Let the deletion is being performed into left sub tree then we
have three types of rotations L(0) rotation ,L(-1) rotation and L(+1) rotation.[2] Here the authors of
both the reviewed papers have demonstrated the searching, insertion and deletion operations on an
AVL tree.
Figure 3 Deletion operation
III. CONCLUSION
Creators of the AVL tree proposed the various rotation schemes for balancing the BST for both
insertion and deletion. To implement these rotations a care has to be taken that whether the new node
will be in the left of the left subtree, left of the right subtree, right of the left subtree or right of the
right subtree. Similar approach has to be applied in case of deletion also. In this paper we reviewed
all these operations on an AVL tree.
REFERENCES
[1] Rajeev R. Kumar Tripathi. Balancing of AVL Tree Using Virtual Node. International Journal of Computer
Applications Volume 7– No.14, October 2010.
[2] Siddharth Nair, Simran Singh Oberoi, Shubham Sharma. Avl tree and its
operations. 2014 IJIRT | Volume 1 Issue 6
[3] https://www.cs.rochester.edu/~gildea/csc282/slides/C12-bst.pdf

More Related Content

What's hot

Sienna 6 bst
Sienna 6 bstSienna 6 bst
Sienna 6 bstchidabdu
 
Stacks, Queues, Binary Search Trees - Lecture 1 - Advanced Data Structures
Stacks, Queues, Binary Search Trees -  Lecture 1 - Advanced Data StructuresStacks, Queues, Binary Search Trees -  Lecture 1 - Advanced Data Structures
Stacks, Queues, Binary Search Trees - Lecture 1 - Advanced Data StructuresAmrinder Arora
 
R-Trees and Geospatial Data Structures
R-Trees and Geospatial Data StructuresR-Trees and Geospatial Data Structures
R-Trees and Geospatial Data StructuresAmrinder Arora
 
Introduction of Data Structure
Introduction of Data StructureIntroduction of Data Structure
Introduction of Data StructureMandavi Classes
 
Eigen value and eigen vectors shwetak
Eigen value and eigen vectors shwetakEigen value and eigen vectors shwetak
Eigen value and eigen vectors shwetakMrsShwetaBanait1
 
Lect 13, 14 (final)AVL Tree and Rotations.pdf
Lect 13, 14 (final)AVL Tree and Rotations.pdfLect 13, 14 (final)AVL Tree and Rotations.pdf
Lect 13, 14 (final)AVL Tree and Rotations.pdfMuhammadUmerIhtisham
 

What's hot (11)

Binary Search Tree
Binary Search TreeBinary Search Tree
Binary Search Tree
 
Avl trees
Avl treesAvl trees
Avl trees
 
Sienna 6 bst
Sienna 6 bstSienna 6 bst
Sienna 6 bst
 
Stacks, Queues, Binary Search Trees - Lecture 1 - Advanced Data Structures
Stacks, Queues, Binary Search Trees -  Lecture 1 - Advanced Data StructuresStacks, Queues, Binary Search Trees -  Lecture 1 - Advanced Data Structures
Stacks, Queues, Binary Search Trees - Lecture 1 - Advanced Data Structures
 
R-Trees and Geospatial Data Structures
R-Trees and Geospatial Data StructuresR-Trees and Geospatial Data Structures
R-Trees and Geospatial Data Structures
 
Lesson 36
Lesson 36Lesson 36
Lesson 36
 
Data structures notes
Data structures notesData structures notes
Data structures notes
 
Tree
TreeTree
Tree
 
Introduction of Data Structure
Introduction of Data StructureIntroduction of Data Structure
Introduction of Data Structure
 
Eigen value and eigen vectors shwetak
Eigen value and eigen vectors shwetakEigen value and eigen vectors shwetak
Eigen value and eigen vectors shwetak
 
Lect 13, 14 (final)AVL Tree and Rotations.pdf
Lect 13, 14 (final)AVL Tree and Rotations.pdfLect 13, 14 (final)AVL Tree and Rotations.pdf
Lect 13, 14 (final)AVL Tree and Rotations.pdf
 

Similar to Study about AVL Tree & Operations

Similar to Study about AVL Tree & Operations (20)

AVL Tree.pptx
AVL Tree.pptxAVL Tree.pptx
AVL Tree.pptx
 
AVL tree PPT.pptx
AVL tree PPT.pptxAVL tree PPT.pptx
AVL tree PPT.pptx
 
4. avl
4. avl4. avl
4. avl
 
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
 
AVL Tree
AVL TreeAVL Tree
AVL Tree
 
Avl trees final
Avl trees finalAvl trees final
Avl trees final
 
9 chapter4 trees_avl
9 chapter4 trees_avl9 chapter4 trees_avl
9 chapter4 trees_avl
 
data structures
data structuresdata structures
data structures
 
Trees in data structure
Trees in data structureTrees in data structure
Trees in data structure
 
Avl tree ppt
Avl tree pptAvl tree ppt
Avl tree ppt
 
Avl trees
Avl treesAvl trees
Avl trees
 
Design data Analysis Avl Trees.pptx by piyush sir
Design data Analysis Avl Trees.pptx by piyush sirDesign data Analysis Avl Trees.pptx by piyush sir
Design data Analysis Avl Trees.pptx by piyush sir
 
AVL_Trees.ppt
AVL_Trees.pptAVL_Trees.ppt
AVL_Trees.ppt
 
3-avl-tree.ppt
3-avl-tree.ppt3-avl-tree.ppt
3-avl-tree.ppt
 
TREES.pptx
TREES.pptxTREES.pptx
TREES.pptx
 
AVL TREE PREPARED BY M V BRAHMANANDA REDDY
AVL TREE PREPARED BY M V BRAHMANANDA REDDYAVL TREE PREPARED BY M V BRAHMANANDA REDDY
AVL TREE PREPARED BY M V BRAHMANANDA REDDY
 
Tree
TreeTree
Tree
 
Ie
IeIe
Ie
 
DS_Mod4_2.pdf
DS_Mod4_2.pdfDS_Mod4_2.pdf
DS_Mod4_2.pdf
 

More from Editor IJCTER

Android Based Solution for Indian Agriculture Management A Design Paper
Android Based Solution for Indian Agriculture Management A Design PaperAndroid Based Solution for Indian Agriculture Management A Design Paper
Android Based Solution for Indian Agriculture Management A Design PaperEditor IJCTER
 
PROGRAMMED TARGET RECOGNITION FRAMEWORKS FOR UNDERWATER MINE CLASSIFICATION
PROGRAMMED TARGET RECOGNITION FRAMEWORKS FOR UNDERWATER MINE CLASSIFICATIONPROGRAMMED TARGET RECOGNITION FRAMEWORKS FOR UNDERWATER MINE CLASSIFICATION
PROGRAMMED TARGET RECOGNITION FRAMEWORKS FOR UNDERWATER MINE CLASSIFICATIONEditor IJCTER
 
Review on Computer Forensic
Review on Computer ForensicReview on Computer Forensic
Review on Computer ForensicEditor IJCTER
 
Comparison of various page Rank Algorithms
Comparison of various page Rank AlgorithmsComparison of various page Rank Algorithms
Comparison of various page Rank AlgorithmsEditor IJCTER
 
A Survey- Knapsack Problem Using Dynamic Programming
A Survey- Knapsack Problem Using Dynamic ProgrammingA Survey- Knapsack Problem Using Dynamic Programming
A Survey- Knapsack Problem Using Dynamic ProgrammingEditor IJCTER
 
PRIVATE CLOUD SERVER IMPLEMENTATIONS FOR DATA STORAGE
PRIVATE CLOUD SERVER IMPLEMENTATIONS FOR DATA STORAGEPRIVATE CLOUD SERVER IMPLEMENTATIONS FOR DATA STORAGE
PRIVATE CLOUD SERVER IMPLEMENTATIONS FOR DATA STORAGEEditor IJCTER
 
A SERVEY ON WIRELESS SENSOR NETWORK SECURITY ISSUES & CHALLENGES
A SERVEY ON WIRELESS SENSOR NETWORK SECURITY ISSUES & CHALLENGESA SERVEY ON WIRELESS SENSOR NETWORK SECURITY ISSUES & CHALLENGES
A SERVEY ON WIRELESS SENSOR NETWORK SECURITY ISSUES & CHALLENGESEditor IJCTER
 
5G Wireless Technology
5G Wireless Technology5G Wireless Technology
5G Wireless TechnologyEditor IJCTER
 
BEE BASED ROUTING PROTOCOL FOR MANET
BEE BASED ROUTING PROTOCOL FOR MANETBEE BASED ROUTING PROTOCOL FOR MANET
BEE BASED ROUTING PROTOCOL FOR MANETEditor IJCTER
 
ALL ABOUT DATA AGGREGATION IN WIRELESS SENSOR NETWORKS
ALL ABOUT DATA AGGREGATION IN WIRELESS SENSOR NETWORKSALL ABOUT DATA AGGREGATION IN WIRELESS SENSOR NETWORKS
ALL ABOUT DATA AGGREGATION IN WIRELESS SENSOR NETWORKSEditor IJCTER
 

More from Editor IJCTER (10)

Android Based Solution for Indian Agriculture Management A Design Paper
Android Based Solution for Indian Agriculture Management A Design PaperAndroid Based Solution for Indian Agriculture Management A Design Paper
Android Based Solution for Indian Agriculture Management A Design Paper
 
PROGRAMMED TARGET RECOGNITION FRAMEWORKS FOR UNDERWATER MINE CLASSIFICATION
PROGRAMMED TARGET RECOGNITION FRAMEWORKS FOR UNDERWATER MINE CLASSIFICATIONPROGRAMMED TARGET RECOGNITION FRAMEWORKS FOR UNDERWATER MINE CLASSIFICATION
PROGRAMMED TARGET RECOGNITION FRAMEWORKS FOR UNDERWATER MINE CLASSIFICATION
 
Review on Computer Forensic
Review on Computer ForensicReview on Computer Forensic
Review on Computer Forensic
 
Comparison of various page Rank Algorithms
Comparison of various page Rank AlgorithmsComparison of various page Rank Algorithms
Comparison of various page Rank Algorithms
 
A Survey- Knapsack Problem Using Dynamic Programming
A Survey- Knapsack Problem Using Dynamic ProgrammingA Survey- Knapsack Problem Using Dynamic Programming
A Survey- Knapsack Problem Using Dynamic Programming
 
PRIVATE CLOUD SERVER IMPLEMENTATIONS FOR DATA STORAGE
PRIVATE CLOUD SERVER IMPLEMENTATIONS FOR DATA STORAGEPRIVATE CLOUD SERVER IMPLEMENTATIONS FOR DATA STORAGE
PRIVATE CLOUD SERVER IMPLEMENTATIONS FOR DATA STORAGE
 
A SERVEY ON WIRELESS SENSOR NETWORK SECURITY ISSUES & CHALLENGES
A SERVEY ON WIRELESS SENSOR NETWORK SECURITY ISSUES & CHALLENGESA SERVEY ON WIRELESS SENSOR NETWORK SECURITY ISSUES & CHALLENGES
A SERVEY ON WIRELESS SENSOR NETWORK SECURITY ISSUES & CHALLENGES
 
5G Wireless Technology
5G Wireless Technology5G Wireless Technology
5G Wireless Technology
 
BEE BASED ROUTING PROTOCOL FOR MANET
BEE BASED ROUTING PROTOCOL FOR MANETBEE BASED ROUTING PROTOCOL FOR MANET
BEE BASED ROUTING PROTOCOL FOR MANET
 
ALL ABOUT DATA AGGREGATION IN WIRELESS SENSOR NETWORKS
ALL ABOUT DATA AGGREGATION IN WIRELESS SENSOR NETWORKSALL ABOUT DATA AGGREGATION IN WIRELESS SENSOR NETWORKS
ALL ABOUT DATA AGGREGATION IN WIRELESS SENSOR NETWORKS
 

Recently uploaded

High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations120cr0395
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...Call Girls in Nagpur High Profile
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Dr.Costas Sachpazis
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130Suhani Kapoor
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Christo Ananth
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINESIVASHANKAR N
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝soniya singh
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Serviceranjana rawat
 
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptxthe ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptxhumanexperienceaaa
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingrknatarajan
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingrakeshbaidya232001
 

Recently uploaded (20)

High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
 
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptxthe ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writing
 

Study about AVL Tree & Operations

  • 1. International Journal of Current Trends in Engineering & Research e-ISSN 2455–1392 Volume 1 Issue 2, December 2015 pp. 8-11 http://www.ijcter.com @IJCTER-2015, All rights Reserved 8 Study about AVL Tree & Operations Viraj Mehta1 , Kapil Prajapati2 1,2 Indira Gandhi National Open University Abstract—AVL tree is the first dynamic tree in data structure which minimizes its height during insertion and deletion operations. This is because searching time is directly proportional to the height of binary search tree (BST). When insertion operation is performed it may result into increasing the height of the tree and when deletion is performed it may result into decreasing the height. To make the BST a height balance tree (AVL tree) creators of the AVL tree proposed various rotations. This paper shows BST and its operation and AVL. Keyword— AVL, BST I. INTRODUCTION A binary search tree is a binary tree with a special property called the BST-property, which is given as follows: For all nodes x and y, if y belongs to the left subtree of x, then the key at y is less than the key at x, and if y belongs to the right subtree of x, then the key at y is greater than the key at x. We will assume that the keys of a BST are pairwise distinct. Each node has the following attributes: • p, left, and right, which are pointers to the parent, the left child, and the right child, respectively, and • key, which is key stored at the node. Example: Figure 1: BST Traversal of the Nodes in a BST By traversal" we mean visiting all the nodes in a graph. Traversal strategies can be specied by the ordering of the three objects to visit: the current node, the left subtree, and the right subtree. We assume the the left subtree always comes before the right subtree. Then there are three strategies. 1. Inorder. The ordering is: the left subtree,the current node, the right subtree. 2. Preorder. The ordering is: the current node, the left subtree, the right subtree.
  • 2. International Journal of Current Trends in Engineering & Research (IJCTER) Volume 01, Issue 02; October– 2015 pp 1-4 @IJCTER-2015, All rights Reserved 9 3. Postorder. The ordering is: the left subtree, the right subtree, the current node. The AVL tree is named after its two Soviet inventors, Georgy Adelson-Velsky and E.M. Landis, who published it in their 1962 paper "An algorithm for the organization of information".[1] It take O(log n) time for the basic operations. We know that every AVL tree is a BST (Binary Search Tree) while every BST is not an AVL tree.[2] AVL tree is a selfbalancing binary search tree. 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. Insertions and deletions may require the tree to be rebalanced by one or more tree rotations. II. OPERATIONS ON AVL TREE 2.1 Searching Searching in an AVL tree is done as in any binary search tree. The special thing about AVL trees is that the number of comparisons required, i.e. The AVL tree's height, is guaranteed never to exceed log (n). 2.2 Traversal Once a node has been found in a balanced tree, the next or previous nodes can be explored in amortized constant time. Some instances of exploring these "nearby" nodes require traversing up to log(n) links (particularly when moving from the rightmost leaf of the root's left subtree to the root or from the root to the leftmost leaf of the root's right subtree; in the example AVL tree, moving from node 14 to the next but one node 19 takes 4 steps). However, exploring all n nodes of the tree in this manner would use each link exactly twice: one traversal to enter the subtree rooted at that node, another to leave that node's subtree after having explored it. And since there are n−1 links in any tree, the amortized cost is found to be 2×(n−1)/n, or approximately 2. After inserting a node, it is necessary to check each of the node's ancestors for consistency with the rules of AVL ("retracing"). The balance factor is calculated as follows: balanceFactor = height(left subtree) -height(right subtree). Since with a single insertion the height of an AVL subtree cannot increase by more than one, the temporary balance factor of a node will be in the range from −2 to +2. For each node checked, if the balance factor remains in the range from −1 to +1 then only corrections of the balance factor, but no rotations are necessary. However, if balance factor becomes less than −1 or greater than +1, the subtree rooted at this node is unbalanced.[1] Rotations in Insertion Operation In case of insertion, we have following rotations. 2.2.1 LL Rotation When a node X is inserted in the left sub tree of left sub tree of node N. 2.2.2 RR Rotation When a node X is inserted in the right sub tree of right sub tree of node N. [2] Pictorial description of how rotations rebalance an AVL tree. The numbered circles represent the nodes being rebalanced. The lettered triangles represent subtrees which are themselves balanced AVL trees. A blue number next to a node denotes possible balance factors (those in parentheses occurring only in case of deletion). Figure 2 2.3 Deletion Let node X be the node with the value we need to delete, and let node Y be a node in the tree we need to find to take node X's place, and let node Z be the actual node we take out of the tree. Deleting a node with two children from a binary search tree using the in-order predecessor (rightmost node in the left subtree, labelled 6).
  • 3. International Journal of Current Trends in Engineering & Research (IJCTER) Volume 01, Issue 02; October– 2015 pp 1-4 @IJCTER-2015, All rights Reserved 10 Figure 2 AVL Tree Steps to consider when deleting a node in an AVL tree are the following: 1. If node X is a leaf or has only one child, skip to step 5 with Z: =X. 2. Otherwise, determine node Y by finding the largest node in node X's left subtree (the inorder predecessor of X − it does not have a right child) or the smallest in its right subtree (the in-order successor of X − it does not have a left child). 3. Exchange all the child and parent links of node X with those of node Y. In this step, the in-order sequence between nodes X and Y is temporarily disturbed, but the tree structure doesn't change. 4. Choose node Z to be all the child and parentlinks of old node Y = those of new node X. 5. If node Z has a subtree (which then is a leaf) attach it to Z's parent. 6. If node Z was the root (its parent is null), update root. 7. Delete node Z.
  • 4. International Journal of Current Trends in Engineering & Research (IJCTER) Volume 01, Issue 02; October– 2015 pp 1-4 @IJCTER-2015, All rights Reserved 11 8. Retrace the path back up the tree (starting with node Z's parent) to the root, adjusting the balance factors as needed. [1] Rotations in Deletion Operation In case of deletion, we have following rotations. 2.3.1 Let the deletion is being performed into right sub tree then we have three types of rotations R(0) rotation ,R(-1) rotation and R(+1) rotation. 2.3.2 Let the deletion is being performed into left sub tree then we have three types of rotations L(0) rotation ,L(-1) rotation and L(+1) rotation.[2] Here the authors of both the reviewed papers have demonstrated the searching, insertion and deletion operations on an AVL tree. Figure 3 Deletion operation III. CONCLUSION Creators of the AVL tree proposed the various rotation schemes for balancing the BST for both insertion and deletion. To implement these rotations a care has to be taken that whether the new node will be in the left of the left subtree, left of the right subtree, right of the left subtree or right of the right subtree. Similar approach has to be applied in case of deletion also. In this paper we reviewed all these operations on an AVL tree. REFERENCES [1] Rajeev R. Kumar Tripathi. Balancing of AVL Tree Using Virtual Node. International Journal of Computer Applications Volume 7– No.14, October 2010. [2] Siddharth Nair, Simran Singh Oberoi, Shubham Sharma. Avl tree and its operations. 2014 IJIRT | Volume 1 Issue 6 [3] https://www.cs.rochester.edu/~gildea/csc282/slides/C12-bst.pdf