You are on page 1of 1

Time : 1 hr

Minor Test I August 10 MCS101: Design and Analysis of Algorithms Max Marks : 20

1. Consider the following algorithm and write a recurrence relation for its time complexity: Ter_search(sorted list x of n elements, t) Let p and q be the elements that divide the list into 3 equal parts If t = x[p] return p Else If t < x[p] then ter-search(first third of the list). Else if t = x[q] return q Else if t < x[q] then ter-search(second third of the list). Else ter-search(last third of the list). 2. Derive the function f(n) such that T(n) = theta(f(n)) T(n) = T(n/3) + T(2n/3) + 1 T(1) = 1 5 3. Compute the KMP failure links for the following pattern abefabefgabefgh 5 4. Given n large integers x1xn a. What is the input size? Denote it by B. Is B = Omega(n)? Is B = O(n)? b. Give a polynomial time algorithm to sort them. Justify the running time of your algorithm. (2+5)

You might also like