What is the cut-off for switching from quick sort to heap sort in the implementation of introsort?

Lan Anh

New member
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)
 
Answer: d
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.
 

Tìm kiếm

Back
Top