We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 24f4090 commit 211c28bCopy full SHA for 211c28b
1 file changed
src/main/java/com/thealgorithms/sorting/BubbleSort.java
@@ -0,0 +1,16 @@
1
+package com.thealgorithms.sorting;
2
+
3
+public class BubbleSort {
4
+ public static void bubbleSort(int[] arr) {
5
+ int n = arr.length;
6
+ for (int i = 0; i < n - 1; i++) {
7
+ for (int j = 0; j < n - i - 1; j++) {
8
+ if (arr[j] > arr[j + 1]) {
9
+ int temp = arr[j];
10
+ arr[j] = arr[j + 1];
11
+ arr[j + 1] = temp;
12
+ }
13
14
15
16
+}
0 commit comments