import java.util.*;
public class quick
{
private static double[] arr;
public static void main(String[] args)
{
int i;
Scanner in=new Scanner(System.in);
System.out.print("Enter n::");
int n=in.nextInt();
arr=new double[n+1];
for(i=0;i
for(i=0;i
quick(0,n-1);
System.out.println("\n\n**************After Sorting****************\n");
for(i=0;i
}
public static void quick(int low,int high)
{
if(low
int j=partition(low,high);
quick(low,j-1);
quick(j+1,high);
}
}
public static int partition(int low,int high)
{
double pivot = arr[low];
int i = low;
int j = high;
double temp;
do
{
do
{
i++;
}while(arr[i]
while(arr[j]>pivot)
j--;
if(i
temp = arr[i];
arr[i]= arr[j];
arr[j]= temp;
}
}while(i
//swap pivot n a[j];
arr[low] = arr[j];
arr[j] = pivot;
return j;
}
}
No comments:
Post a Comment