FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
basic-programs/java/BubbleSort.java at master · ProjectRipo/basic-programs · GitHub
ProjectRipo
/
basic-programs
Public
forked from
utkarsh-shekhar/basic-programs
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
basic-programs
/
java
/
BubbleSort.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
35 lines (29 loc) · 1.22 KB
Breadcrumbs
basic-programs
/
java
/
BubbleSort.java
Copy path
File metadata and controls
35 lines (29 loc) · 1.22 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
public
class
BubbleSort
{
static
void
bubbleSort
(
int
[]
arr
) {
int
n
=
arr
.
length
;
int
temp
=
0
;
for
(
int
i
=
0
;
i
<
n
;
i
++){
for
(
int
j
=
1
;
j
< (
n
-
i
);
j
++){
if
(
arr
[
j
-
1
] >
arr
[
j
]){
//swap elements
temp
=
arr
[
j
-
1
];
arr
[
j
-
1
] =
arr
[
j
];
arr
[
j
] =
temp
;
}
}
}
}
public
static
void
main
(
String
[]
args
) {
int
arr
[] ={
3
,
60
,
35
,
2
,
45
,
320
,
5
};
System
.
out
.
println
(
"Array Before Bubble Sort"
);
for
(
int
i
=
0
;
i
<
arr
.
length
;
i
++){
System
.
out
.
print
(
arr
[
i
] +
" "
);
}
System
.
out
.
println
();
bubbleSort
(
arr
);
//sorting array elements using bubble sort
System
.
out
.
println
(
"Array After Bubble Sort"
);
for
(
int
i
=
0
;
i
<
arr
.
length
;
i
++){
System
.
out
.
print
(
arr
[
i
] +
" "
);
}
}
}
Back
|
FazBrowse Home
|
New Git URL