From 5e6c583719d3a0d74bb74aeae0918593cc314626 Mon Sep 17 00:00:00 2001 From: 3024753 <3024753@stud.hs-mannheim.de> Date: Tue, 31 Mar 2026 18:25:59 +0200 Subject: [PATCH 1/2] =?UTF-8?q?Kommentar=20in=20QuickSort.java=20hinzugef?= =?UTF-8?q?=C3=BCgt=20als=20finalen=20Test=20des=20Committens=20f=C3=BCr?= =?UTF-8?q?=20das=20morgige=20Testat?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PR2pvl/src/QuickSort.java | 51 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 PR2pvl/src/QuickSort.java diff --git a/PR2pvl/src/QuickSort.java b/PR2pvl/src/QuickSort.java new file mode 100644 index 0000000..aa24b9a --- /dev/null +++ b/PR2pvl/src/QuickSort.java @@ -0,0 +1,51 @@ + + public class QuickSort { + + public static void quickSort(int[] arr, int low, int high) { + if (low < high) { + // Pivot-Index bestimmen + int pivotIndex = partition(arr, low, high); + + // Linke Seite sortieren + quickSort(arr, low, pivotIndex - 1); + + // Rechte Seite sortieren + quickSort(arr, pivotIndex + 1, high); + } + } + + private static int partition(int[] arr, int low, int high) { + int pivot = arr[high]; // letztes Element als Pivot + int i = low - 1; + + for (int j = low; j < high; j++) { + if (arr[j] <= pivot) { + i++; + + // Tauschen + int temp = arr[i]; + arr[i] = arr[j]; + arr[j] = temp; + } + } + + // Pivot an richtige Position setzen + int temp = arr[i + 1]; + arr[i + 1] = arr[high]; + arr[high] = temp; + + return i + 1; + } + + // Test + public static void main(String[] args) { + int[] arr = {8, 3, 1, 7, 0, 10, 2}; + + quickSort(arr, 0, arr.length - 1); + + for (int num : arr) { + System.out.print(num + " "); + } + } + //End of Class + } -- 2.43.0 From 0d33b585c40acf206c0e9d59ed2cc10b52002d7e Mon Sep 17 00:00:00 2001 From: 3024753 <3024753@stud.hs-mannheim.de> Date: Tue, 31 Mar 2026 18:29:21 +0200 Subject: [PATCH 2/2] test --- PR2pvl/src/SelectionSort.java | 29 ----------------------------- 1 file changed, 29 deletions(-) diff --git a/PR2pvl/src/SelectionSort.java b/PR2pvl/src/SelectionSort.java index c4f065e..35bcab1 100644 --- a/PR2pvl/src/SelectionSort.java +++ b/PR2pvl/src/SelectionSort.java @@ -93,33 +93,4 @@ public class SelectionSort { } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - } \ No newline at end of file -- 2.43.0