CSC 345 Section 8.6
An exchange sort is: Another name for Insertion Sort Any Θ(n^2) sort Any Θ(n) sort Any sort where only adjacent records are swapped Any sort where records are swapped rather than using another mechanism for rearranging the array
Any sort where only adjacent records are swapped
Consider an array A of n records each with a unique key value, and A_R the same array in reverse order. There are a certain number of pairs, where an arbitrary position ii and position j is a pair. Between these two arrays, exactly half of these pairs must be inverted. True False
False
If I is the number of inversions in an input array of n records, then {Insertion|Bubble} Sort will require how many swaps? n^2/2 n - 1 I + n I
I
Consider an array A of n records each with a unique key value, and A_R the same array in reverse order. Any given pair of records must be an inversion in exactly one of A or A_R. True False
True
An inversion is: A swap When a record with key value greater than the current record's key appears before it in the array A type of sort
When a record with key value greater than the current record's key appears before it in the array
How many ways can n distinct values be arranged? n n(n+1)/2 n^2 n! 2^n
n!
The total number of pairs of records among n records is: n! n nlogn n^2/2 n(n+1)/2 n(n−1)/2 2n n!/2 2n^2
n(n−1)/2
The average number of inversions in an array of n records is n(n-1)/4. This is: Worse than Θ(n^2) Θ(n^2) Better than Θ(n^2)
Θ(n^2)