Page 1

Introduction to Algorithms 19 June 2013 1. (20%)A stable sorting algorithm is one that preserves the original order of equal keys. Which of the following sorting algorithms are stable? which are unsrtable? a. Bubble Sort. b. Bucket Sort. c. Counting Sort. d. Exchange Sort. e. Heapsort. f. Insertion Sort. g. Mergesrot. h. Qicksort. i. Radix Sort. j. Selection Sort. 2. (15%)Draw a decision tree corresponding to Selection Sort when sorting three keys. 3. (15%)Suppose that we are to find the k smallest elements in a list of n elements, and we are not interested in their relative order. Can a linear-time algorithm be found when k is a constant? Justify your answer. 4. (20%)Let S and T be two arrays of n numbers that are already in nondecreasing order. Write an algorithm that finds the median of all 2n numbers whose complexity is in Θ(lg n) . 5. Let a weighted and directed graph be given. A Hamiltonian cycle is a cycle that visits every vertex exactly once. The Traveling Salesperson Optimization problem is to determine a Hamiltonian cycle with minimum total weight on its edges. a. (10%)Please define the Traveling Salesperson Decision problem. b. (20%)Propose a nondeterministic polynomial-time algorithm for the Traveling Salesperson Decision problem .

Read more
Read more
Similar to
Popular now
Just for you