FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
JavaSortAlgoritmalari/QuickSort.java at master · furkanyunkul/JavaSortAlgoritmalari · GitHub
furkanyunkul
/
JavaSortAlgoritmalari
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
JavaSortAlgoritmalari
/
QuickSort.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
49 lines (39 loc) · 1.16 KB
Breadcrumbs
JavaSortAlgoritmalari
/
QuickSort.java
Copy path
File metadata and controls
49 lines (39 loc) · 1.16 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
import
java
.
util
.
Arrays
;
public
class
QuickSort
{
public
static
void
quick_sort
(
int
[]
anArray
,
int
size
){
recursiveQuickSort
(
anArray
,
0
,
anArray
.
length
-
1
);
}
public
static
void
recursiveQuickSort
(
int
[]
array
,
int
startIdx
,
int
endIdx
) {
int
pivotIndex
=
partition
(
array
,
startIdx
,
endIdx
);
if
(
startIdx
<
pivotIndex
-
1
) {
recursiveQuickSort
(
array
,
startIdx
,
pivotIndex
-
1
);
}
if
(
endIdx
>
pivotIndex
) {
recursiveQuickSort
(
array
,
pivotIndex
,
endIdx
);
}
}
public
static
int
partition
(
int
[]
array
,
int
left
,
int
right
) {
int
pivot
=
array
[
left
];
while
(
left
<=
right
) {
while
(
array
[
left
]<
pivot
) {
left
++;
}
while
(
array
[
right
]>
pivot
) {
right
--;
}
if
(
left
<=
right
) {
int
tmp
=
array
[
left
];
array
[
left
]=
array
[
right
];
array
[
right
]=
tmp
;
left
++;
right
--;
}
}
return
left
;
}
public
static
void
main
(
String
[]
args
) {
int
liste
[] = {
12
,
11
,
13
,
5
,
6
,
7
};
quick_sort
(
liste
,
liste
.
length
);
System
.
out
.
println
(
Arrays
.
toString
(
liste
));
}
}
Back
|
FazBrowse Home
|
New Git URL