void quicksort(int x[], int l, int u)
{
int * j; int k;
if (l > =u)
return;
else
{
partition (x, l,u,&j);
quicksort (x, l, j -1);
quicksort (x, j+1, u);
return;
}
}
void partition (int x [], int l, int u,int *j)
{
int k, m,n, i, temp, int * j;
k = x [l]; /* k is the element whose final */
n = u; /* position is required */
m =l;
while (m <>
{
while (x[m] <= k && m <>
m++ ; /* move the lower index up */
while (x[n] > k)
n --; /* reduce the upper index */
if (m
{
/*interchange x[m] & x[n] */
temp=x[m];
x[m]=x[n];
x[n]=temp;
} /* end if */
} * end while */
x[l]= x[n];
x[n]=k;
* j = n;
return;
}
No comments:
Post a Comment