-
Notifications
You must be signed in to change notification settings - Fork 62
Expand file tree
/
Copy pathBubbleSort.java
More file actions
33 lines (30 loc) · 755 Bytes
/
BubbleSort.java
File metadata and controls
33 lines (30 loc) · 755 Bytes
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
public class BubbleSort {
public static void BubbleSort( int [ ] no )
{
int j;
boolean flag = true;
int temp;
while ( flag )
{
flag= false;
for( j=0; j < no.length -1; j++ )
{
if ( no[ j ] < no[j+1] )
{
temp = no[ j ];
no[ j ] = no[ j+1 ];
no[ j+1 ] = temp;
flag = true;
}
}
}
for(int p = 0 ;p<no.length;p++)
{
System.out.println(" "+no[p]);
}
}
public static void main(String[] args) {
int[] no = {10,20,30,70,90,02,03,05,65,72,23};
BubbleSort(no);
}
}