Aufgaben weiter bearbeitet

main
mail 2026-03-30 14:46:22 +02:00
parent 5543fc1f16
commit 3f0efbca79
1 changed files with 15 additions and 0 deletions

View File

@ -29,6 +29,21 @@ public class Tabelle {
//Selectionsort O(n) O(n^2) //Selectionsort O(n) O(n^2)
//Insertionsort O(n) O(n^2) //Insertionsort O(n) O(n^2)
//Zur Klärung der "Sockenfrage" berechnen Sie die Anzahl der Vergleiche für gute (n log n)!!! und
//schlechte (n^2)!!! Sortieralgorithmen für 2 x 10 Elemente (Socken) und für 20 Elemente. Was fällt Ihnen auf?
//Gute(2*10): 10*log2(10) = 10*3,32 = 33,2 --> 2*33,2 = 66 (ungefähre ergebnisse)
//Schlechte(2*10): 10^2 = 100 (Ein Array Länge 10) --> 2*100 = 200 Vergleiche (Sind ja zwei Arrays)
//Gute(20): 20*log2(20) = 20*4,32 = 86 (ungefäre ergebnisse)
//Schlechte(20): 20^2 = 400 Vergleiche
//CompareTO integer rückgabewert
//Bsp: String var1 = "Hallo";
// var1.compareTo("HalloWelt");
//Bei positiv kommt der wert nach rechts
//Bei negativ nach links
//Bei 0 ist er gleich
public static int bubblesort (int[] arr) { public static int bubblesort (int[] arr) {
int d = 0; int d = 0;
int temp = -1; int temp = -1;