diff --git a/app/src/main/java/ch/nuth/zhaw/exbox/SortServer.java b/app/src/main/java/ch/nuth/zhaw/exbox/SortServer.java index bbaede8..0a825fd 100644 --- a/app/src/main/java/ch/nuth/zhaw/exbox/SortServer.java +++ b/app/src/main/java/ch/nuth/zhaw/exbox/SortServer.java @@ -34,7 +34,11 @@ public class SortServer implements CommandExecutor { } private void insertionSort(int[] a) { - for (int k = 0; k < a.length; k++) { + insertionSort(a, 0, a.length - 1); + } + + private void insertionSort(int[] a, int min, int max) { + for (int k = min; k < max + 1; k++) { int item = a[k]; int newIndex; @@ -46,19 +50,6 @@ public class SortServer implements CommandExecutor { } } - private void insertionSort(int[] a, int l, int r) { - for (int k = l + 1; k < r + 1; k++) { - if (a[k] < a[k - 1]) { - int x = a[k]; - int i; - for (i = k; ((i > 0) && (a[i - 1] > x)); i--) { - a[i] = a[i - 1]; - } - a[i] = x; - } - } - } - private void selectionSort(int[] a) { // TODO Implement Aufgabe 3 for (int i = 0; i < a.length; i++) {