r c letter 71 90 A 54 80 B 39 70 C 26 60 D
Name: Answer key
Multiple choice problems (2 points each)
C. O(lg(n)) < O(n) < O(n*lg(n)) < O(n2) < O(2n)
D. Heap sort and mergesort
B. to determine the k-th smallest element in an array for given array and k.
D. None of the above
B. n2/2
A. It rearranges the array somewhat.
C. Both A and B.
C. Provably, any algorithm that solves the problem must use at least about n + lg(n) comparisons.
D. All of the above.
A. randomizedSelect has the fewer comparisons in practice (average/expected number of comparisons).
A. Has an expected case number of comparisons E(n) which is O(n).
D. None of the above
A. both Boyer-Moore and Knuth-Morris-Pratt algorithms require no more than O(nm) comparisons.
C. When the data is dynamic, with many insertions/deletions of items as well as look-ups.
C. between 16 and 256
C. no node has two red children
A. the colors of a black node and it's two red children are flipped.
C. a temporary situation in which a red node has a red child is fixed.
B. 2
D. 10
B. O(lg(n))
B. O(lg(n))
B. O(lg(n))
D. Neither A nor B
A. Insertion sort
| v 123456789 123456789 123456789 123456789 123456789 123456789 12345 no analog of asymptotic complexity exists in research on bananas. banana banana (next position on basis of charjump) banana (next position on basis of matchjump) banana (next position chosen - best of the two) 19 comparisons are made. Compared chars are in caps (_ for blank): no_ANAloG of aSymptoTic coMplexiTy exiSts in_reseaRch on_BANANAs. baNANA bananA bananA bananA bananA bananA bananA bananA bananA bananA BANANA
W(n) = n + sum from i = 2 to n-1 of lg(i). B.
W(n) = about n + n*lg(n) = about n*lg(n) = O(n lg(n))
Solution: consult text or online samples.