Elementary sorting
1.[3p] How many inversions does the array 5, 2, 4, 6, 1, 3 contain?
How many inversions does the array 5, 2, 4, 6, 1, 3 contain?
2.[3p] Insertion sort's number of moves is exactly equal to
Insertion sort's number of moves is exactly equal to
3.[2p] How many comparisons does selection sort make on an array of 1000 elements that is already sorted?
How many comparisons does selection sort make on an array of 1000 elements that is already sorted?
4.[2p] A random permutation of elements has, on average, how many inversions?
A random permutation of elements has, on average, how many inversions?
5.[3p] Which of these are true of selection sort?
Which of these are true of selection sort?
Select all that apply
6.[3p] To order a table by department and, within each department, by surname, using a stable sort, you should
To order a table by department and, within each department, by surname, using a stable sort, you should
7.[2p] Insertion sort runs in linear time on input whose inversion count is .
Insertion sort runs in linear time on input whose inversion count is .
8.[2p] An insertion sort takes 5.0 seconds on 100,000 random records. Roughly how many seconds does it take on 400,000 random records?
An insertion sort takes 5.0 seconds on 100,000 random records. Roughly how many seconds does it take on 400,000 random records?
9.[3p] Any algorithm that only swaps adjacent elements is stuck at on random input because
Any algorithm that only swaps adjacent elements is stuck at on random input because