MCPcopy Create free account
hub / github.com/TheAlgorithms/Java / sort

Method sort

src/main/java/com/thealgorithms/sorts/CombSort.java:39–50  ·  view source on GitHub ↗

Method to sort the array using CombSort @param arr the array to be sorted @param the type of elements in the array @return the sorted array

(T[] arr)

Source from the content-addressed store, hash-verified

37 * @return the sorted array
38 */
39 @Override
40 public <T extends Comparable<T>> T[] sort(T[] arr) {
41 int gap = arr.length;
42 boolean swapped = true;
43
44 while (gap != 1 || swapped) {
45 gap = getNextGap(gap);
46 swapped = performSwaps(arr, gap);
47 }
48
49 return arr;
50 }
51
52 /**
53 * Method to perform the swapping of elements in the array based on the current gap

Callers

nothing calls this directly

Calls 2

getNextGapMethod · 0.95
performSwapsMethod · 0.95

Tested by

no test coverage detected