Sorting · Class 12 · CBSE · Science Computer Science

For an already sorted list of n elements, explain why insertion sort can be more efficient than selection sort, and state the best-case time complexi…

Practice question from Sorting (Class 12 · CBSE · Science Computer Science), with the correct answer and a step-by-step solution.

hard · Subjective · Q-445B2A

For an already sorted list of n elements, explain why insertion sort can be more efficient than selection sort, and state the best-case time complexity of each algorithm.

Answer: In an already sorted list, insertion sort only compares each element with its predecessor and performs no shifting, so its best-case time complexity is O(n). Selection sort still searches the remaining unsorted portion for the minimum element during every pass, giving it a best-case time complexity of O(n²).

Solution

Insertion sort detects that each element is already in the correct relative position, so it makes only a linear number of comparisons. Selection sort performs nearly the same minimum-selection work regardless of the initial order, resulting in quadratic time.

More from Sorting

All of Sorting

Practise more Computer Science

Sign up free for adaptive practice on this chapter, with instant feedback and hints on every question.

Start practising free

Free to start · No credit card needed