Quicksort recursion depth Stack space of O(n) doesnot cause stackoverflow?
问题 In Worst case Quicksort recursion Depth requires Stack space of O(n). Why it doesn't cause a stack overflow for large set in the worst case? (reversed sequence) 回答1: If you recurse on both sides of the pivot then it does cause stack overflow for sufficiently large data in the worst case. That's why nobody uses a naive QuickSort in production code. There is a simple change you can make to the algorithm to prevent Omega(n) worst-case stack use. After each partition, recursively Quicksort the