PDA

View Full Version : CS301 Data Structures Assignment # 3 May 2010



Awais
05-14-2010, 10:21 PM
CS301 – Data Structures
Assignment No.3
Mark: 20
Deadline

Your assignment must be uploaded/submitted at or before May 17, 2010

Assignment


Question
Consider a binary search tree (BST) that is initially empty. Draw the tree that will result if the following numbers are inserted in the same order given below: 5 Marks

13, 3,1,2,4,12,10,5,8,7,6,9,11,14,15,18


After making a BST perform the following operations on it.

a) Pre order Traversal 5 Marks
b) Inorder Traversal 5 Marks
c) Postorder Traversal 5 Marks

viki
05-17-2010, 09:48 PM
Solution

Binary Search Tree (BST) drawn with the following numbers when inserted in the same order as given 13,3,1,2,4,12,10,5,8,7,6,9,11,14,15,18
201

a. Pre order Traversal

13,3,1,4,2,12,10,5,11,8,7,9,6,14,15,18

b. In Order Traversal

1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,18

c. Post Order Traversal

2,1,6,7,8,9,5,10,11,12,4,3,18,15,14,13