forked from narnolii/java-DSA
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQuick_sort.java
More file actions
75 lines (46 loc) · 1.16 KB
/
Quick_sort.java
File metadata and controls
75 lines (46 loc) · 1.16 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
public class Quick_sort{
static void quickr(int a[] ,int first ,int last){
int pivot = a[last];
int fi = first;
int la = last;
for(int i=0;i<a.length;i++){
if(a[pivot]>a[fi]){
a[fi]++;
}
else if(a[pivot]<a[fi]){
int temp;
temp=a[pivot];
a[pivot]=a[fi];
a[fi]=temp;
}
else if(a[la]>a[pivot]){
a[la]--;
}
else if(a[la]<a[pivot]){
int temp;
temp=a[pivot];
a[pivot] = a[la];
a[la]=temp;
else(a[ls]==a[fi]){
quickr();
}
}
}
}
}
static void quick(int a[],int start,int last){
if(start>=last){
return 0;
}
quickr(a,start ,mid,last);
quick(a, start , mid);
quick(a,mid+1,last);
}
public static void main(){
int a[] ={4,3,7,2,78,23};
quick(a);
for(int i=0;i<a.length;i++){
System.out.println("array is : "+a[i]);
}
}
}