The point at which the Introsort algorithm switches from Quicksort to Heapsort is determined by the depth_limit value:
depth_limit = 2 ยท โฃlog 2 (l) โฆ
Where l is the length of the sequence to be sorted, so l = n for the entire sequence. With each recursive call, depth_limit decreases by one. When depth_limit reaches 0, it switches from Quicksort to Heapsort.
source share