void quicksort( T[] A, Integer left, Integer right)
if ( left < right )
q = partition( A, left, right) ;
quicksort ( A, left, q–1);
quicksort ( A, q+1, right) ;
Integer partition( T[] A, Integer left, Integer right)
m = left + right / 2;
swap( A[left], A[m]);
pivot = A[left] ;
lo = left+1; hi = right;
while ( lo ≤ hi )
while ( A[hi] > pivot )
hi = hi – 1;
while ( lo ≤ hi and A[lo] <
∼ pivot )
lo = lo + 1;
if ( lo ≤ hi )
swap( A[lo], A[hi]);
lo = lo + 1; hi = hi – 1;
swap( A[left], A[hi]);
return hi
plz tell me the case for (lo=hi) in while loop in partition.
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.