Welcome to Scribd. Sign in or start your free trial to enjoy unlimited e-books, audiobooks & documents.Find out more
Download
Standard view
Full view
of .
Look up keyword
Like this
49Activity
0 of .
Results for:
No results containing your search query
P. 1
a complete guide for building a AVL Tree

a complete guide for building a AVL Tree

Ratings:

4.67

(1)
|Views: 10,250|Likes:
Published by Suvayan
a complete guide for inserting & deleting nodes in a AVL Tree.........by following this tutorial any body new to data structure, can make a correct and complete AVL tree , which is generally a sore point for not only beginners also the pros.
a complete guide for inserting & deleting nodes in a AVL Tree.........by following this tutorial any body new to data structure, can make a correct and complete AVL tree , which is generally a sore point for not only beginners also the pros.

More info:

Published by: Suvayan on Jul 06, 2009
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

02/01/2013

pdf

text

original

 
1
Suvayan 9231937821 suvayanbala@gmail.com
 
Page | 1
Drawing an AVL TREE:-
Steps for insertion:-
1.
 
Insert the numbers in Binary Search Tree (BST)pattern.2.
 
Before the next number is inserted, perform thefollowing operations :-a)
 
Find out the balance factor of each node.
 
b)
 
Balance Factor of a node = (Maximum numberof levels that can be reached in right sub-tree ) – ( Maximum number of levels that can bereached in left sub tree )[WE TAKE LEVEL OF THE STARTING NODEAS 0]c)
 
If any of the Balance Factor is (-2) or (2),perform required rotation according to thealgorithm given below. If two nodes have (2/-2)then select the lowest node in level.d)
 
 The tree now become balanced, i.e. no nodehas Balance Factor (-2) or (2). Continue fromstep 1.
Rotation Algorithm
[Right heavy (B.F. = 2), Left heavy (B.F. = -2)]
 
IF tree is right heavy (B.F. = 2)IF tree's right sub tree is left heavy (B.F. = -2 / -1)Perform Left-Right (LR) rotation
 
2
Suvayan 9231937821 suvayanbala@gmail.com
 
Page | 2
 }ELSEPerform Left rotation } }ELSE IF tree is left heavy (B.F. = -2)IF tree's left sub tree is right heavy (B.F. = 2 / 1)Perform Right-Left Rotation (RL) rotation }ELSEPerform Right rotation } }
ROTATIONS
Left Left Case Right Right Case
 
( Right Rotation ) (
 
Left Rotation )
 
 
3
Suvayan 9231937821 suvayanbala@gmail.com
 
Page | 3
Left - Right Case ( LR Rotation )
 
Left rotation Right rotation
 Right - Left Case ( RL Rotation )
 

Activity (49)

You've already reviewed this. Edit your review.
1 hundred reads
1 thousand reads
Anurag Tiwari liked this
Salman Ali liked this
Justine Bartolo liked this
Tziuka Sambor liked this
Fazal Munna liked this
Ankita Singh liked this
Justine Bartolo liked this
Janice Loza liked this

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->