Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

AVL Trees Construction-Data Structure-Assignment Solution, Exercises of Data Structures and Algorithms

I am student at Baddi University of Emerging Sciences and Technologies. To help my friends in other universities, I am uploading my solved assignments of different courses. Its for Data Structure course. Other can see if they are searching following: Avl, Trees, Construction, Data, Insert, Rotation, Rotate, Child, Node

Typology: Exercises

2011/2012
On special offer
30 Points
Discount

Limited-time offer


Uploaded on 08/01/2012

parmitaaaaa
parmitaaaaa 🇮🇳

4.2

(111)

179 documents

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Course: CS301(DataStructures)
AssignmentNo.3:Solution.
AVL
Trees construction.
Data for construction of AVL tree,
(10, 5 , 3 , 15 , 17 , 19 , 21, 25 , 24 , 22 )
StepByStepSolution:
Insert 10 Insert 5 Insert 3 (non-AVL) AVL
10 10 10 5
5 5 Single 3 10
rotation
3
Insert 15 Insert 17 (non-AVL) AVL
5
5 5
3 10 3
10
15 15
Single 3 15
rotation
10 17
17
Insert 19 (non-AVL) AVL Insert 21 (non-AVL)
15 15
5
Single 5 17 5 17
3 15
rotation
3 10 19
10 17
19
3 10 19
21
docsity.com
pf3
Discount

On special offer

Partial preview of the text

Download AVL Trees Construction-Data Structure-Assignment Solution and more Exercises Data Structures and Algorithms in PDF only on Docsity!

Course: CS301 (Data Structures)

Assignment No. 3: Solution.

AVL Trees construction.

Data for construction of AVL tree,

Step By Step Solution:

Insert 10 Insert 5 Insert 3 (non-AVL) AVL

5 5 Single^3 rotation 3

Insert 15 Insert 17 (non-AVL) AVL

Single 3 15 rotation 10 17 17

Insert 19 (non-AVL) AVL Insert 21 (non-AVL)

Single (^5 17 5 ) 3 15 rotation 3 10 19 10 17 19

AVL Insert 25 Insert 24 (non-AVL)

Single rotation 5 19 5 19 5 19 3 10 17 21 3 10 17 21

Step 1: Rotate child and grandchild Step 2: Rotate node and new child (AVL)

Double 5 19 5 19 rotation 3 10 17 21 3 10 17 24 24 21 25 25

Insert 22 (non-AVL) Step 1: Rotate child and Step 2: Rotate node and

grandchild new child (AVL)

15 5 19 3 10 17 21

Double rotation (^5 ) 24 3 10 17 25 15 5 21 21