Hello, I'm implementing different sort algorithms as an excercise. However, I'm not sure how to implement quick sort algorithm.
Here's recursive implementation:
How to implement nonrecursive quick sort. I know I'll need stack,
void quick_sort(int* array,int l,int r)
int partition(int* array, int l, int r)
while((array[i] <= pivot) && (i <= r))i++;
while((array[j] > pivot) && (j > l))j--;
if(i < j)
void swap_in_array(int* array, int i, int j)
and I manage to implement stack using single linked list.
Asssuming prototipes are:
void push(Stack* stack,int);
how code for quic sort would look like?
I don't need implamentation for stack, I've done that, but I need implementation for nonrecursive quick_sort.
I've searched the board, but found nothing to help me.
I hope you'll help me.
Thanks very much!