Dear,
There are some missing statement in your program.
Please compare following code with your source code.
public class QuickSort{
public static void main(String a[]){
int i;
int array[] = {12,9,4,99,120,1,3,10,13};
System.out.println("Values Before the sort:\n");
for(i = 0; i < array.length; i++)
System.out.print( array[i]+" ");
System.out.println();
quick_srt(array,0,array.length-1);
System.out.print("Values after the sort:\n");
for(i = 0; i <array.length; i++)
System.out.print(array[i]+" ");
System.out.println();
System.out.println("PAUSE");
}
public static void quick_srt(int []k,int lb,int ub) {
boolean flag=true;
int i,j,key,temp;
if(lb<ub)
{
i=lb;
j=ub+1;
key=k[lb];
while(flag) {
i++;
while(k[i]<key && i<ub)
i++;
j--;
while(k[j]>key && j>lb)
j--;
if(i<j) {
temp=k[i]; k[i]=k[j]; k[j]=temp;
}
else
flag=false;
}
temp=k[lb];
k[lb]=k[j];
k[j]=temp;
quick_srt(k,lb,j-1);
quick_srt(k,j+1,ub);
}
}
} __avd
Posting Genius (adatapost)
Moderator
8,647 posts since Oct 2008
Reputation Points: 2,136
Solved Threads: 1,241