Mergesort. Sort left half (recursively), sort right half (recursively), merge.
Merge. Understand how to carry out the merge operation. How many compares to merge two arrays, each of length n/2, in the best case? In the worst case?
Mergesort order of growth. Understand how to show that the order of growth of the number of compares is n log_2 n. Understand why the entire algorithm is also order n log_2 n.
Mergesort compare bounding. Know why the best case is ~ 1/2 n log_2 n and the worst case is ~ n log_2 n compares.
Mergesort properties. Mergesort is stable (why?). Mergesort uses n extra memory (why?). Does mergesort do particularly well on already sorted arrays? Partially ordered arrays?
Sorting lower bound. Any compare-based sorting algorithm requires at least ~ n log_2 n compares in the worst case to sort an array of length n.
Bottom-up mergesort. Non-recursive version of mergsort.
Timsort. Optimized version of mergesort used in Python and Java system sorts.
Suppose that the variable cards is an array of cards. We could sort it, using your compareTo function, with a call to MergeX.sort(cards). Which of the following code fragments would produce an equivalent final result? Circle all equivalent code fragments.
Option 1: MergeX.sort(cards, Card.bySuitOrder()); MergeX.sort(cards, Card.byRankOrder()); Option 2: MergeX.sort(cards, Card.byRankOrder()); MergeX.sort(cards, Card.bySuitOrder()); Option 3: MergeX.sort(cards); MergeX.sort(cards, Card.bySuitOrder()); Option 4: MergeX.sort(cards, Card.byRankOrder()); MergeX.sort(cards); Option 5: Quick.sort(cards, Card.bySuitOrder()); Quick.sort(cards, Card.byRankOrder()); Option 6: Quick.sort(cards, Card.byRankOrder()); Quick.sort(cards, Card.bySuitOrder()); Option 7: MergeX.sort(cards); Quick.sort(cards, Card.bySuitOrder()); Option 8: Quick.sort(cards, Card.byRankOrder()); MergeX.sort(cards);Answers