-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSort.java
More file actions
36 lines (31 loc) · 751 Bytes
/
Sort.java
File metadata and controls
36 lines (31 loc) · 751 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import java.lang.Math;
import java.util.Random;
public class Sort{
static void QuickSort(int data[],int low, int high){
int i = low;
int j = high;
if(i>j) return ;
int key = data[i];
while(i<j){
while(i<j && data[j]>=key)
j--;
data[i] = data[j];
while(i<j && data[i]<=key)
i++;
data[j] = data[i];
}
data[i] = key;
QuickSort(data,low,i-1);
QuickSort(data,i+1,high);
}
public static void main(String[] args) {
// TODO Auto-generated method stub
long start=System.currentTimeMillis();
Random ramdon = new Random();
int temp[] ={5,45,47,584,48,184,547,65,9,54};
QuickSort(temp,0,temp.length-1);
for(int i =0 ;i< temp.length;i++)
System.out.print( temp[i]+" ");
System.out.println( );
}
}