diff --git a/Algorithm/code/bubbleSort.java b/Algorithm/code/bubbleSort.java new file mode 100644 index 00000000..93ee323c --- /dev/null +++ b/Algorithm/code/bubbleSort.java @@ -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)); +}