MA60002 Data Structure and Algorithms (Bhakt)
MA60002 Data Structure and Algorithms (Bhakt)
MA60002 Data Structure and Algorithms (Bhakt)
Answer ALL QUESTIONS. All the notations are standard and no query or doubts will be
entertained. If any data/statement is missing, identify it in your answer script. Marks are
indicated at the end of each question.
l. Consider the recurrence T(n) = T(n/2) + T(n/4) + n. Use the substitution method to
give a tight upper bound on the solution to the recurrence using O-notation. [2)
2. For each of the following algorithms, (i) give a recurrence that describes its worst-case
running time and (ii) its worst-case running time using 8-notation: (a) Binary search, (b)
Insertion Sort, (c) Merge Sort, (d) Randomized quicksort and (e) Strassen's algorithm. [5)
3. Consider the following sorting methods: Insertion Sort, Merge Sort, and Quick Sort. What
is the running time using O-notation for each method
5. (a) Write a pseudo-code for finding the k-th largest element in an array of n elements in
linear time without using any extra storage.
(h) Illustrate the above algorithm on the following sequence by finding the 3-rd largest
element:
13,14,15,16,17,12,11,10,9
(c) Explain why the average computing time of the above algorithm is linear. [2 + 1 + 1)
--P.T.O.--
6. (a) Use the integer hash function h(x) = x mod 11 and table size 11. Using chaining with
separate lists, show the location in the hash table for each integer value in the following
sequence:
7,21,45,40,65,98,44,67
(b) Use the same hash function and give the table constructed by the linear probe method.
7. TRUE OR FALSE? If the statement is correct, briefly state why. If the statement is
wrong, explain why. [6]
(a) By the master theorem, the solution to the recurrence T(n) = 3T(n/3) + log2 n is
T(n) = 8(nlog2n).
(b) Let Fk denote the k-th Fibonacci number. Then, the n2th Fibonacci number Fn2
can be computed in o (1og2n) time.
(c) There exists a comparison sort of 5 numbers that uses at most 6 comparisons in the
worst case.
(d) Let S be a set of n integers. One can create a data structure for S so that determining
whether an integer x belongs to S can be performed in 0(1) time in the worst case.
(e) Suppose that an array contains n numbers, each of which is -1, 0 or 1. Then, the array
can be sorted in O(n) time in the worst case.
() Let AI, A2 and A3 be three sorted arrays on n real numbers (all distinct). In the
comparison model, constructing a balanced binary search tree of the set Al U A2 U A3
requires Q( n log2 n).