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. 10
- C. 15
- D. 20
Answer: B. 10
Explanation: Selection sort comparisons are n(n-1)/2 regardless of order. 5*4/2 = 10.