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
|
package
SeleniumMakeItEasy;
import
org.apache.commons.lang3.ArrayUtils;
public
class BubbleSort{
public
static void main(String[] args){
int[]
a = {2,3,2,5,3,3,6,1,2,5};
int
l = a.length;
for(int
i=0;i<l; i++){
for(int
j=0; j<l-1; j++){
if(a[j]>a[j+1]){
a[j]
= a[j] + a[j+1];
a[j+1]
= a[j] - a[j+1];
a[j]
= a[j] - a[j+1];
}else
if(a[j]==a[j+1]){
a
= ArrayUtils.remove(a,j);
l
= a.length;
}
}
}
for(int
s: a){
System.out.println(s);
}
}
}
|
Sunday, September 4, 2016
Java Program For Bubble Sort
Bhanu Namikaze
Author & Editor
Bhanu Namikaze is an Ethical Hacker, Passionate Blogger, Web Developer, Student and Mechanical Engineer. He Enjoys writing articles, Blogging, Solving Errors, Surfing and Social Networking. Feel Free To Contact Me @ Bhanu.
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment