all tasks
This commit is contained in:
parent
b83f433714
commit
68f8f3e56b
14735 changed files with 178959 additions and 0 deletions
|
|
@ -0,0 +1,14 @@
|
|||
public static <E extends Comparable<? super E>> void bubbleSort(E[] comparable) {
|
||||
boolean changed = false;
|
||||
do {
|
||||
changed = false;
|
||||
for (int a = 0; a < comparable.length - 1; a++) {
|
||||
if (comparable[a].compareTo(comparable[a + 1]) > 0) {
|
||||
E tmp = comparable[a];
|
||||
comparable[a] = comparable[a + 1];
|
||||
comparable[a + 1] = tmp;
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
} while (changed);
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
if (comparable[a].compareTo(comparable[b]) < 0){
|
||||
//same swap code as before
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue