From 10438f9e7ae0905d7bf69705054853dfc2b5313a Mon Sep 17 00:00:00 2001 From: 3024753 <3024753@stud.hs-mannheim.de> Date: Wed, 25 Mar 2026 17:11:14 +0100 Subject: [PATCH] =?UTF-8?q?InsertionSort=20nochmals=20ge=C3=BCbt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PR2pvl/src/InsertionSort.java | 55 ++++++++++++++++------------------- 1 file changed, 25 insertions(+), 30 deletions(-) diff --git a/PR2pvl/src/InsertionSort.java b/PR2pvl/src/InsertionSort.java index fccefe0..9bcf8a5 100644 --- a/PR2pvl/src/InsertionSort.java +++ b/PR2pvl/src/InsertionSort.java @@ -1,35 +1,11 @@ public class InsertionSort { - public static void main(String[] args) {} + public static void main(String[] args) { + System.out.println("Hier ist Insertionsort"); + } - public static int[] insertionSort(int[] sortieren) { - int temp = 0; - - for(int i = 1; i < sortieren.length; i++) { - if(sortieren[i-1] > sortieren[i]) { - temp=sortieren[i]; - sortieren[i]=sortieren[i-1]; - sortieren[i-1]=temp; - - int j = i; - while(j>0) { - if(sortieren[j-1]>sortieren[j]) { - temp=sortieren[j]; - sortieren[j]=sortieren[j-1]; - sortieren[j-1]=temp; - } - j--; - - } - } - } - - - - - return sortieren; - } + public static int[] insertionSortLSG(int[] sortieren) { int temp; @@ -38,10 +14,29 @@ public class InsertionSort { int j = i; while (j > 0 && sortieren[j - 1] > temp) { sortieren[j] = sortieren[j - 1]; - j--; - } + j--; } sortieren[j] = temp; } return sortieren; } } + + + +public static void insertionsorttest(int[] arr){ + int tmp; + for(int i =1; i 0 && arr[j-1]>tmp){ + arr[j] = arr[j-1]; + } + arr[j]=tmp; + } + +} + +void main() { +} +