1.

What is the cut-off for switching from quick sort to heap sort in the implementation of introsort?(a) 16(b) n^2(c) n log(n)(d) 2 log (n)I have been asked this question in quiz.My question is taken from Sorting topic in chapter Sorting of Data Structures & Algorithms II

Answer»

Correct answer is (d) 2 log (n)

Easy EXPLANATION - Quicksort has a worst CASE time complexity of O(n^2) which is not preferable. So in ORDER to avoid worst case of quicksort, INTROSORT switches to heap SORT when the depth is greater than 2 log(n). This particular value has been deduced experimentally.



Discussion

No Comment Found

Related InterviewSolutions