← Quiz: Sorting Basics: all 13 questions
Quiz: Sorting Basics · Question 11 of 13
At most how many swaps does selection sort make on n items?
At most how many swaps does selection sort make on n items?
- A.n²
- B.n log n
- C.n(n − 1) / 2
- D.n − 1
Answer & explanation
Correct answer: n − 1
It makes at most one swap per pass to put the smallest remaining item in front, and there are n − 1 passes.
Can you get the rest right without peeking?
Take the timed Quiz: Sorting Basics quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →