|
The quicksort assignment requires that you refine some pseudocode.
|
Note1: Assume a[n+1] is "large"!
Note2: Except for the word pseudocode, this is Java!
pseudocode quicksort(int[] a, int m, int n)
{
if ( m < n ) {
int i = m; int j = n + 1; int k = a[m];
for (;;) {
do { i++; } while ( a[i] <= k );
do { j--; } while ( a[j] >= k );
if ( i < j ) {
interchange(a,i,j);
} else {
break;
}
}
interchange(a,m,j);
display("WITHIN QUICKSORT ...",a);
quicksort(a,m,j-1);
quicksort(a,j+1,n);
}
}
|