/* related posts with thumb nails */

Program to implement Quick Sort.:

import java.io.*;

class QuickSort

{

public static void qsort(int a[],int min,int max)

{

int t,v,i,j;

if (max > min)

{

v = a[max];

i=min;

j = max-1;

do

{

while ((a[i]

i++;

while ((a[j]>v) && j!=0)

j--;

t = a[i];

a[i] = a[j];

a[j] = t;

} while (j > i);

a[j] = a[i];

a[i] = a[max];

a[max] = t;

qsort(a,min,i-1);

qsort(a,i+1,max);

}

}

public static void main(String as[]) throws Exception

{

int i,n,a[]=new int[10];

InputStreamReader isr=new InputStreamReader(System.in);

BufferedReader br=new BufferedReader(isr);

System.out.println("How many values:");

n=Integer.parseInt(br.readLine());

System.out.println("Enter Values:");

for(i=0;i

a[i]=Integer.parseInt(br.readLine());

qsort(a,0,n-1);

System.out.println("After Sorting");

for(i=0;i

System.out.print("\t"+a[i]);

}

}

Output:

How many values: 4

Enter Values:

45

36

87

12

After Sorting:

12 36 45 87

Related Topics:

1 comments:

Unknown said...

What is the difference between casino games and slots?
Slot games are the most popular types of casino games, and the majority are poormansguidetocasinogambling slots. kadangpintar goyangfc and the most commonly played gri-go.com slot games. casino-roll.com

Post a Comment