← 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?
- A.Selection sort
- B.Insertion sort
- C.All three take the same time
- 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 →