Skip to content

Commit

Permalink
2019-11-16 [Algorithm] bubbleSort code Add
Browse files Browse the repository at this point in the history
  • Loading branch information
gyoogle authored Nov 16, 2019
1 parent 2dbfaa9 commit e4a4737
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Algorithm/code/bubbleSort.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
void bubbleSort(int[] arr) {
int temp = 0;
for(int i = 0; i < arr.length; i++) {
for(int j= 1 ; j < arr.length-i; j++) {
if(arr[j-1] > arr[j]) {
temp = arr[j-1];
arr[j-1] = arr[j];
arr[j] = temp;
}
}
}
System.out.println(Arrays.toString(arr));
}

0 comments on commit e4a4737

Please sign in to comment.