all tasks
This commit is contained in:
parent
b83f433714
commit
68f8f3e56b
14735 changed files with 178959 additions and 0 deletions
|
|
@ -0,0 +1,18 @@
|
|||
public static <E extends Comparable<? super E>> void sort(E[] input) {
|
||||
int gap = input.length;
|
||||
boolean swapped = true;
|
||||
while (gap > 1 || swapped) {
|
||||
if (gap > 1) {
|
||||
gap = (int) (gap / 1.3);
|
||||
}
|
||||
swapped = false;
|
||||
for (int i = 0; i + gap < input.length; i++) {
|
||||
if (input[i].compareTo(input[i + gap]) > 0) {
|
||||
E t = input[i];
|
||||
input[i] = input[i + gap];
|
||||
input[i + gap] = t;
|
||||
swapped = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue