How many comparisons are needed to sort an array of length 5 if a straight…
2008
How many comparisons are needed to sort an array of length 5 if a straight selection sort is used and array is already in the opposite order?
- A.
1
- B.
5
- C.
10
- D.
20
Attempted by 760 students.
Show answer & explanation
Correct answer: C
Straight selection sort performs a fixed number of comparisons based on the array size, regardless of whether the array is sorted or in reverse order. The total number of comparisons for an array of size n is given by the formula n(n-1)/2. Substituting n=5, we get 5(4)/2 = 10 comparisons.