CS 580 Homework Assignment #2 (Due: Wed, Feb. 11)
- [10 point] We saw in the class that the most efficient comparison-based sorting algorithm takes O(n lg n) time. Using decision tree, we proved that any comparison sort algorithm requires Omega(n lg n) comparisons in worst case. Now we will make use of adversary argument to prove this fact. Using adversary argument, prove that any comparison sort algorithm requires Omega(n lg n) comparisons to sort an array of n integers in worst case.
- [10 point] We saw in class that the SELECT algorithm can find the k th largest element in O(n) worst-case time. Now, using adversary argument, prove that n - 1 + min(k - 1, n - k) is a lower bound on the number of comparisons needed to find the k th largest element in an n-element array.
- [20 point] Consider an n-element array A[1..n]:
- Give an O(n)-time algorithm to determine if any element of A appears atleast n/2 times in A. If such an element exists, your algorithm should return its value; else it should return NULL.
- Give an O(nk)-time algorithm to determine if any element of A appears atleast n/k times in A. If such an element exists, your algorithm should return its value; else it should return NULL.
- [20 point] Problem 9-2 (a,b,c,d), Page 194.
- [10 point] Problem 33.4-1, Page 961.
- [10 point] Problem 33.4-2, Page 961.
- [10 point] Exercises 8.2-3, Page 170.
- [10 point] Exercises 8.3-4, Page 173.