// insertion sort on n elements, reverse-sorted inputWhat is the worst-case complexity?
- A
O(n log n)
- B
O(n)
- C
O(log n)
- Dcheck_circle
O(n^2)
Explanation
Reverse-sorted input forces maximum shifts each iteration: O(n^2).
AP Computer Science A· difficulty 2/5
// insertion sort on n elements, reverse-sorted inputWhat is the worst-case complexity?
O(n log n)
O(n)
O(log n)
O(n^2)
Explanation
Reverse-sorted input forces maximum shifts each iteration: O(n^2).
Want 10 more like this — adaptive to your weak spots?