This action might not be possible to undo. Are you sure you want to continue?

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 the following operations :a) Find out the balance factor of each node. b) Balance Factor of a node = (Maximum number of levels that can be reached in right sub-tree ) – ( Maximum number of levels that can be reached in left sub tree ) [WE TAKE LEVEL OF THE STARTING NODE AS 0] c) If any of the Balance Factor is (-2) or (2), perform required rotation according to the algorithm given below. If two nodes have (2/-2) then select the lowest node in level. d) The tree now become balanced, i.e. no node has Balance Factor (-2) or (2). Continue from step 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

Suvayan – 9231937821 suvayanbala@gmail.com Page | 1

F. = -2) { IF tree's left sub tree is right heavy (B.F.com Page | 2 . = 2 / 1) { Perform Right-Left Rotation (RL) rotation } ELSE { Perform Right rotation } } ROTATIONS Left – Left Case ( Right Rotation ) Right – Right Case ( Left Rotation ) Suvayan – 9231937821 suvayanbala@gmail.2 } ELSE { Perform Left rotation } } ELSE IF tree is left heavy (B.

com Page | 3 .3 Left .Right Case ( LR Rotation ) Left rotation Right rotation Right .Left Case ( RL Rotation ) Suvayan – 9231937821 suvayanbala@gmail.

com Page | 4 . c) If the node has two sub-trees (left/right).4 Right rotation Left rotation AVL TREE showing the Balance Factor 2 0 -1 0 0 0 0 Steps for deletion:1. just remove it from the tree. This can be done by the following operations:a) If the node has no leaf node. b) If the node has only one sub-tree (left/right). just remove the node and replace it by its immediate child node. remove the Suvayan – 9231937821 suvayanbala@gmail. Delete the number in Binary Search Tree (BST) pattern.

b) Balance Factor of a node = (Maximum number of levels that can be reached in right sub-tree ) – (Maximum number of levels that can be reached in left sub tree) [WE TAKE LEVEL OF THE STARTING NODE AS 0] c) If any of the Balance Factor is (-2) or (2). Suvayan – 9231937821 suvayanbala@gmail. 2. the node that will be written just after the deleted node in inorder traversal).5 node and replace it by its immediate inorder traversal node (i.e. If no nodes have (2/-2) then the AVL Tree is still balanced and no further rearranging is not required. When the deletion of node and reordering of the tree is done. perform required rotation according to the algorithm given above. Perform the following operations:a) Find out the balance factor of each node.com Page | 5 . continue from the next step. If two nodes have (2/-2) then select the lowest node in level.

- AVL TREE LECTURE
- AVL Tree Program
- Trees_data structures
- An introduction to AVL Tree
- Comparison of All Sorting Algorithms
- AVLTreeTutorial
- data structures
- B TREE TUTORIAL PPT
- Types of Binary Tree
- AVL Tree Animation
- Queue
- Observer and Observable
- Stack Data Structure
- AVL Trees
- Queue Data Structure
- Queue data structure
- AVL tree
- Weight Balanced Binary Tree
- MAT1801 Past Paper 2011/2012 Full Solution
- DS through Java
- Role of Data Structure in Compiler Design
- Sample Data Structures Questions
- B+ TREE TUTORIAL PPT
- C++ Project on Hotel Room Reservation
- C program for list implementation using linked list
- C program for Binary Search Tree
- Graph Theory - Douglas B West - 2 Ed
- Introduction to the Design & Analysis of Algorithms 2ND Edition by Anany Levitin
- Past Paper 2009/2010 Full Solution
- Fundamentals of Algorithmics - Brassard, Bratley
- a complete guide for building a AVL Tree

Are you sure?

This action might not be possible to undo. Are you sure you want to continue?

We've moved you to where you read on your other device.

Get the full title to continue

Get the full title to continue reading from where you left off, or restart the preview.

scribd