- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbubblesor.java
More file actions
Latest commit
28 lines (23 loc) · 698 Bytes
/
Copy pathbubblesor.java
File metadata and controls
28 lines (23 loc) · 698 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
publicclassbubblesor{
publicstaticvoidbubbleSort(intarr[] ) {
for (intturn = 0; turn < arr.length-1; turn++) {
for( intj=0;j<arr.length-1-turn;j++){
if(arr[j]>arr[j+1]){
inttemp=arr[j];
arr[j]=arr[j+1];
arr[j+1]=temp;
}
}
}
}
publicstaticvoidprintArr(intarr[] ) {
for (inti = 0; i < arr.length; i++) {
System.out.println( );
}
}
publicstaticvoidmain(String[] args) {
intarr[]={5,4,1,3,2};
bubbleSort(arr);
printArr(arr);
}
}