The document outlines the mid-term examination for the Design and Analysis of Algorithm course at the National Institute of Technology, Rourkela, for the Spring Semester of 2023. It includes a series of questions covering various algorithmic concepts, including time complexity, recurrence relations, sorting algorithms, and search algorithms. Students are required to answer any ten questions from the provided list within a duration of two hours for a total of 30 marks.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
4 views2 pages
CS2006
The document outlines the mid-term examination for the Design and Analysis of Algorithm course at the National Institute of Technology, Rourkela, for the Spring Semester of 2023. It includes a series of questions covering various algorithmic concepts, including time complexity, recurrence relations, sorting algorithms, and search algorithms. Students are required to answer any ten questions from the provided list within a duration of two hours for a total of 30 marks.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2
NATIONAL INSTITUTE OF TECHNOLOGY, ROURKELA
MID-TERM EXAMINATION, SPRING SEMESTER- 2023
ANSWER ANY TEN QUESTIONS Name of the algorithm mentioned in “ “ are as per the convention of the text book. All Parts of a question should be answered at one place. SUBJECT: Design and Analysis of Algorithm Subject Code: CS2006 FULL MARKS : 30 Duration of Examination: 2 Hours 1[a] Show that n! = O(nn)? 1[b] Solve the recurrence relation: T(n) = 3 T(n/2) =cn for n > 1 ; T(n) = d for n=1 1[c] Define an algorithm's time and space complexity. Suppose it is known that the running time of one algorithm is O ( log N) and that the running time of another algorithm is O (N 2). What does this say about the relative performance of algorithms? [1+1+1] 2[a] State the Master's Theorem? 2[b] Solve the recurrence relation: T(n) = 4 T(n-1) - 3 T(n-2) + 4n ; T(0) = 1, T(1) = 1. 2[b] Let T(n) = the number of moves to move a Tower of n disks from the source peg to the target peg. Write the recurrence relation for T(n) based upon the recursive Towers of the Hanoi algorithm. Solve this recurrence relation. [1+1+1] 3[a] Differentiate between performance analysis and performance measurement of an algorithm? 3[b] Write an algorithm to compute xn ? Obtain the step count for your algorithm using the frequency method to find asymptotic complexity. [1+2] [4] Suppose a[1:m] and b[1:n] contain sorted elements in non-decreasing order. Write an algorithm "Merge" that merges these items into c[1:m+n] single sorted sequences in O (n) time. Is it possible to design an efficient algorithm in comparison to "Merge"? If elements of array a[1:m] are equal, then comment on the algorithm's complexity. [3] [5] What is the pre-condition for performing a binary search in a linear array? Write the algorithm of binary search. Modify binary search so that it always returns the smallest (largest) index of a key of an item matching the search key. What is the worst-case complexity of your algorithm? [3] [6] Define the Selection Problem. How is the quick sort used to find the solution to the selection problem [Find the kth LARGEST element from an array of n elements] with the help of an algorithm (Quickselect)? Show that the average time complexity of the algorithms is O (n). [3] [7] Show that average time complexity of "QuickSort" is (n log n)? Show that work space needed by Algorithm "QuickSort" varies between (log n) and (n)? What is its average space complexity? [3] [8] Define and differentiate between deterministic and non-deterministic algorithm? Suggest a non-deterministic primality testing algorithm? What is the time complexity of the proposed algorithm? [3] Page 1 of 2 [9] Consider the modified binary search algorithm so that it splits the input not into two sets of almost-equal sizes but into three sets of sizes, approximately one-third. Write an algorithm for ternary search, and find the asymptotic complexity of this algorithm. What is the worst- case complexity of your algorithm? [3] [10] Consider the following modification of the algorithm "MergeSort". The algorithm first divides the input array A[low...high] into four parts A1, A2, A3 and A4 instead of two. It then sorts each part recursively, and finally merges the four sorted parts to obtain the original array in sorted order. Assume for simplicity that n is a power of 4. Write out the modified algorithm. Analyze its running time. [3] [11] Suppose that you have an N-story building and plenty of eggs. Suppose also that an egg is broken if it is thrown off floor F or higher, and unbroken otherwise. First, devise an algorithm to determine the value of F such that the number of broken eggs is (log N), when using (log N) throws, then find a way to reduce the cost to (2 log F) , when N is much larger than F. [3] [12] You have a mixed pile of N nuts and N bolts and need to quickly find the corresponding pairs of nuts and bolts. Each nut matches exactly one bolt, and each bolt matches exactly one nut. By fitting a nut and bolt together, you can see which is bigger. But it is not possible to directly compare two nuts or two bolts. Given an efficient method for solving the problem. [3] [13] Write an algorithm using divide-and-conquer paradigm for finding the position of the largest element in an array of n numbers. What will be your algorithm's output for arrays with several elements of the largest value? Write the recurrence relation for the number of key comparisons made by your algorithm? [3] [14] What is a randomized algorithm? Design a randomized algorithm rsearch(A, n, x) which will search whether x is in the array A of n elements. If found it will terminate. Otherwise, the algorithm is guaranteed to terminate when it finds that none of the elements in A is x. What is the time complexity of your algorithm? [3] [15] Write the control Abstraction for Divide-and-Conquer paradigm? Write the recurrence relation to compute the time taken by a Divide and Conquer algorithm, to solve defective chessboard problem with size [2K 2k, with k 0]? Solve the recurrence relation using substitution method. [3] [16] Write a divide-conquer recursive algorithm "MaxMin" to find the maximum and minimum from a set of n elements. Modify Algorithm "MaxMin" so that it works when n is not a power of 2. Is the number of comparisons performed by the new algorithm 3n/2-2, even if n is not a power of 2? [3]
--------------------------------------- Good luck ---------------------------------------