1.

In which case will tim sort will work as an insertion sort?(a) when no. of elements are less than 64(b) when no. of elements are greater than 64(c) when no. of elements are less than size of run(d) when no. of elements are less than 32I have been asked this question in semester exam.My question comes from Sorting topic in section Sorting of Data Structures & Algorithms II

Answer»

Correct answer is (c) when no. of elements are less than size of run

Easiest explanation - Tim sort uses a hybrid of INSERTION and MERGE sort. It reduces to insertion sort when the size of array is less than the size of run as insertion sort is EFFICIENT in sorting SMALL arrays.



Discussion

No Comment Found

Related InterviewSolutions