← Quiz: Searching and Sorting in C: all 10 questions
Quiz: Searching and Sorting in C · Question 5 of 10
What is the best-case time of insertion sort, and when does it happen?
What is the best-case time of insertion sort, and when does it happen?
- A.O(n²), on sorted input
- B.O(n), on already sorted input
- C.O(log n), on sorted input
- D.O(1), on reverse-sorted input
Answer & explanation
Correct answer: O(n), on already sorted input
On sorted input each new element is already in place, so the inner loop stops after one comparison.
Can you get the rest right without peeking?
Take the timed Quiz: Searching and Sorting in C quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →