MCPcopy Create free account
hub / github.com/KrishGaur1354/Java-Projects-for-Beginners / bubble

Method bubble

Bubble-Sort/bubblesort.java:9–25  ·  view source on GitHub ↗
(int[] arr)

Source from the content-addressed store, hash-verified

7 System.out.println(Arrays.toString(arr));
8 }
9 static void bubble(int[] arr) {
10 boolean swapped;
11 for(int i = 0 ; i < arr.length ; i++){
12 swapped = false;
13 for(int j = 1 ; j < arr.length - i ; j++) {
14 if(arr[j] < arr[j-1]) {
15 int change = arr[j];
16 arr[j] = arr[j-1];
17 arr[j-1] = change;
18 swapped = true;
19 }
20 }
21 if (!swapped) {
22 break;
23 }
24 }
25 }
26}

Callers 1

mainMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected