Tail Call Is Not Enough
This quicksort replaces the second recursive call with a loop, the standard tail-call elimination:
void qsort_tail(int a[], int p, int r) {
while (p < r) {
int q = partition(a, p, r);
qsort_tail(a, p, q - 1);
p = q + 1;
}
}
What is its worst case stack depth, and what change bounds it at ?
Sign in to answer questions and track your progress
Sign In