A. to determine the median of 5 elements.
B. to determine the k-th smallest element in an array for given array and k.
C. To choose a "Comparator" function to use on the median problem.
D. to determine the ripest apple in a barrel. lecture 1
Ans: B
A. Algorithm S uses fewer element comparisons that algorithm T.
B. Algorithm S uses n-1 element comparisons and algorithm T uses n lg(n).
C. Both A and B
D. Neither A nor B
Ans: D. Both use n-1 comparisons (which is also optimal for the problem).
A. It leaves the array in sorted order.
B. It rearranges the array somewhat.
C. It uses a "partition" function to divide the array exactly in half if the array size is even and into two segments whose sizes differ by one if the array size is odd.
D. It uses O(n lg(n)) array element comparisons.
Ans: B or D must be marked correct. The question writer messed up, probably had Theta, not bigOh, in mind for D. A is wrong because it does not sort completely and C is wrong because the partitioning is not so exact (unfortunately).