We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents ff2dc96 + 0a1f066 commit 064ca1cCopy full SHA for 064ca1c
java/solution/bubble_sort
@@ -0,0 +1,25 @@
1
+public void bubbleSort(int[] arr) {
2
+
3
+ int n = arr.length;
4
5
+ for (int i = 0; i < n – 1; i++) {
6
7
+ for (int j = 0; j < n – i – 1; j++) {
8
9
+ if (arr[j] > arr[j + 1]) {
10
11
+ // Swap arr[j] and arr[j+1]
12
13
+ int temp = arr[j];
14
15
+ arr[j] = arr[j + 1];
16
17
+ arr[j + 1] = temp;
18
19
+ }
20
21
22
23
24
25
+}
0 commit comments