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

Method sift

src/main/java/com/thealgorithms/sorts/SmoothSort.java:109–132  ·  view source on GitHub ↗
(final T[] array, int order, int root)

Source from the content-addressed store, hash-verified

107 }
108
109 private static <T extends Comparable<T>> void sift(final T[] array, int order, int root) {
110 final T value = array[root];
111
112 while (order > 1) {
113 final int right = root - 1;
114 final int left = root - 1 - LEONARDO[order - 2];
115
116 if (!SortUtils.less(value, array[left]) && !SortUtils.less(value, array[right])) {
117 break;
118 }
119
120 if (!SortUtils.less(array[left], array[right])) {
121 array[root] = array[left];
122 root = left;
123 order -= 1;
124 } else {
125 array[root] = array[right];
126 root = right;
127 order -= 2;
128 }
129 }
130
131 array[root] = value;
132 }
133
134 private static <T extends Comparable<T>> void trinkle(final T[] array, long p, int order, int root, boolean trusty) {
135 final T value = array[root];

Callers 2

sortMethod · 0.95
trinkleMethod · 0.95

Calls 1

lessMethod · 0.95

Tested by

no test coverage detected