🎙 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 2 of 13

Which simple sort is fastest on an array that is already almost sorted?

Which simple sort is fastest on an array that is already almost sorted?

  1. A.Selection sort
  2. B.Insertion sort
  3. C.All three take the same time
  4. D.None of them — they are all O(n²) every time
Answer & explanation

Correct answer: Insertion sort

Insertion sort only shifts items that are out of place, so on nearly sorted data it does close to n steps.

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 →