FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
algorithms/src/test/java/sort/basic/BubbleSort.java at master · verifyCode/algorithms · GitHub
verifyCode
algorithms
Repository navigation
Code
Issues
Pull requests
2
(2)
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
algorithms
/
src
/
test
/
java
/
sort
/
basic
/
BubbleSort.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
29 lines (24 loc) · 697 Bytes
Breadcrumbs
algorithms
/
src
/
test
/
java
/
sort
/
basic
/
BubbleSort.java
Copy path
File metadata and controls
29 lines (24 loc) · 697 Bytes
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
package
sort
.
basic
;
import
com
.
sort
.
SortTestHelper
;
import
java
.
util
.
Arrays
;
/**
* @author xjn
* @since 2020-05-07
*/
public
class
BubbleSort
{
public
static
void
sort
(
int
[]
array
) {
for
(
int
i
=
0
;
i
<
array
.
length
;
i
++) {
for
(
int
j
=
1
;
j
<
array
.
length
-
i
;
j
++) {
if
(
array
[
j
-
1
] >
array
[
j
]) {
SortTestHelper
.
swap
(
array
,
j
-
1
,
j
);
}
}
}
}
public
static
void
main
(
String
[]
args
) {
int
[]
ints
=
SortTestHelper
.
generateRandomArray
(
10
,
1
,
10
);
System
.
out
.
println
(
Arrays
.
toString
(
ints
));
sort
(
ints
);
System
.
out
.
println
(
Arrays
.
toString
(
ints
));
}
}
Back
|
FazBrowse Home
|
New Git URL