The limits of sorting
1.[3p] Why must a correct comparison sort of distinct elements have at least leaves in its decision tree?
Why must a correct comparison sort of distinct elements have at least leaves in its decision tree?
The answer is: Two inputs that answer every comparison the same way reach the same leaf and get the same output, so each of the permutations needs its own leaf
The answer is: Two inputs that answer every comparison the same way reach the same leaf and get the same output, so each of the permutations needs its own leaf
The answer is: Two inputs that answer every comparison the same way reach the same leaf and get the same output, so each of the permutations needs its own leaf
2.[2p] What is the smallest number of comparisons that could sort six elements, from the counting bound? Give a whole number.
What is the smallest number of comparisons that could sort six elements, from the counting bound? Give a whole number.
3.[3p] Using , roughly how many comparisons are needed at minimum to sort a million elements? Give the answer in millions.
Using , roughly how many comparisons are needed at minimum to sort a million elements? Give the answer in millions.
4.[2p] The bound is always achievable, so 29 comparisons suffice to sort twelve elements.
The bound is always achievable, so 29 comparisons suffice to sort twelve elements.
The answer is: False
5.[3p] Which of these are true of the lower bound?
Which of these are true of the lower bound?
Select all that apply
The answer is: It applies to the average case as well as the worst case, It says nothing about algorithms that use a key as an array index, Insertion sort finishing in comparisons on sorted input does not contradict it
6.[2p] Counting-sorting 40 keys drawn from the range 0 to 9 costs about operations. What is that total?
Counting-sorting 40 keys drawn from the range 0 to 9 costs about operations. What is that total?
7.[3p] Radix sort would break if its per-digit pass were not stable because
Radix sort would break if its per-digit pass were not stable because
The answer is: ties on the current digit must keep the order established by the lower digits already sorted
The answer is: ties on the current digit must keep the order established by the lower digits already sorted
The answer is: ties on the current digit must keep the order established by the lower digits already sorted
8.[3p] Put these arrays in the order radix sort produces them, starting from 213, 902, 130, 921, 013, 900.
Put these arrays in the order radix sort produces them, starting from 213, 902, 130, 921, 013, 900.
013, 130, 213, 900, 902, 921
130, 900, 921, 902, 213, 013
900, 902, 213, 013, 921, 130
Show the answer
b, a, c
9.[3p] Match each non-comparison sort to the assumption it needs.
Match each non-comparison sort to the assumption it needs.
Counting sort
Radix sort
Bucket sort
Comparison sort
nothing beyond an ordering
keys splittable into fixed-width digits
a key range small enough to index
keys spread evenly over the range
Show the answer
Counting sort: a key range small enough to index Radix sort: keys splittable into fixed-width digits Bucket sort: keys spread evenly over the range Comparison sort: nothing beyond an ordering