Alorithms · Class 12 · CBSE · Science Computer Science

Explain why merge sort is generally preferred over selection sort for sorting a large collection of data. State the time complexity of both algorithm…

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

hard · Subjective · Q-5AFFB3

Explain why merge sort is generally preferred over selection sort for sorting a large collection of data. State the time complexity of both algorithms in the average or worst case.

Answer: Merge sort divides the data into smaller sublists, sorts them, and merges them, achieving O(n log n) time in the average and worst cases. Selection sort repeatedly selects the smallest remaining element and takes O(n²) time, so merge sort is generally more suitable for large collections despite requiring additional memory for merging.

Solution

Merge sort has O(n log n) average and worst-case time complexity, while selection sort has O(n²) complexity. Therefore, merge sort scales better as the input size increases, although it uses extra space during the merge process.

More from Alorithms

All of Alorithms

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