MCPcopy Create free account
hub / github.com/apna-college/Alpha / modifiedBubbleSort

Method modifiedBubbleSort

2_Basic Sorting/BubbleSort.java:19–35  ·  view source on GitHub ↗
(int arr[])

Source from the content-addressed store, hash-verified

17 }
18
19 public static void modifiedBubbleSort(int arr[]) {
20 for(int turn=0; turn<arr.length-1; turn++) {
21 boolean swapped = false;
22 for(int j=0; j<arr.length-1-turn; j++) {
23 if(arr[j] > arr[j+1]) {
24 //swap
25 int temp = arr[j];
26 arr[j] = arr[j+1];
27 arr[j+1] = temp;
28 swapped = true;
29 }
30 }
31 if(swapped == false) {
32 break;
33 }
34 }
35 }
36
37 public static void bubbleSortDescending(int arr[]) {
38 for(int turn=0; turn<arr.length-1; turn++) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected