🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← 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?

  1. A.n²
  2. B.n log n
  3. C.n(n − 1) / 2
  4. 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 →