Download past papers and notes and more Exams Data Structures and Algorithms in PDF only on Docsity!
UNIVERSITY OF THE PUNJAB Fourth Semester 2015 Examination: B.S. 4 Years Programme PAPER: Data Structure and Algorithm TIME ALLOWED: 2 hrs. & 30 mins. Course Code: IT-207/ ā MAX. MARKS: 50 Attempt this Paper on Separate Answer Sheet provided. Part-II (Short Questions) QUESTION #2 [4x 5=20 marks] 1. Draw the Binary Search Tree (BST) obtained when the following values are inserted (in the given order) into an initially empty BST: 1410 8 9 15 13 16 14 You only have to show the final BST which results afier inserting all of the above values. 2. Compute the running time of the program fragment shown below. num = 0; for(i=N; i>0; i--) { iG S. 9): { num = num + 1; } else { for(k=N; k > 0; k--) num = num - 1; } } 3. Write a C++ function leastDifference that finds the least difference between any two elements of an array. For example: Array: 20 24 30 45 32 19 Least Difference: 2 (between 30 and 32) 4. Perform deletion operation of minimum value only one time in the following min- heap and draw the resultant tree after deletion. : P.T.O.