N
nkharan
Hey,
Here is the pseudocode of quicksort. It can be observed that there
are as many as (n-1) unresolved stack calls in the worst case. Now, how
do i reduce this unresolved stack calls? what modifications should I
make?
procedure QuickSort(L[0:n-1], low, high) recursive
Input: L[0:n-1] (a list of size n), low, high (integers)
Output: L[low:high] is sorted
if high > low then
Partition(L[0:n-1], low, high, position)
QuickSort(L[0:n-1], low, position - 1)
QuickSort(L[0:n-1], position + 1, high)
endif
end QuickSort
thanks,
Haran
Here is the pseudocode of quicksort. It can be observed that there
are as many as (n-1) unresolved stack calls in the worst case. Now, how
do i reduce this unresolved stack calls? what modifications should I
make?
procedure QuickSort(L[0:n-1], low, high) recursive
Input: L[0:n-1] (a list of size n), low, high (integers)
Output: L[low:high] is sorted
if high > low then
Partition(L[0:n-1], low, high, position)
QuickSort(L[0:n-1], low, position - 1)
QuickSort(L[0:n-1], position + 1, high)
endif
end QuickSort
thanks,
Haran