New Web Design
Dec 3, 2007 by Brad
I've downloaded this nice, imo, web template so that deepcopy can again look presentable.
Learned a neat trick about quicksort at supercomputing 2007 courtesy of the Cray award winner, Dr. Ken Batcher. Quicksort uses tail recursion, which can lead to a stack overflow. The following solution only creates O(log n) stacks:
quicksort(long A[], int lo, int hi)
{
while (lo < hi) {
int pivot = partition(A, lo, hi);
if (pivot+pivot < lo+hi) {
quicksort(A, lo, pivot - 1);
lo = pivot + 1;
}
else {
quicksort(A, pivot+1, hi);
hi = pivot - 1;
}
}
}
Neat, huh?