1.

Why is insertion sort preferred over other sorting algorithms (like selection sort, bubble sort etc.) for Tim sort implementation?(a) Because insertion sort is faster and adaptive(b) Because insertion sort requires less space(c) Because insertion sort is easy to implement(d) Because insertion sort is easy to understandThis question was posed to me in an interview.The query is from Sorting in chapter Sorting of Data Structures & Algorithms II

Answer»

Correct option is (a) Because insertion sort is faster and adaptive

The BEST explanation: When SMALL arrays need to be sorted then insertion sort proves to be the best choice. Also, it is adaptive so it PERFORMS BETTER than others when the given array is fully/partially sorted.



Discussion

No Comment Found

Related InterviewSolutions