Compare commits

...

5 Commits

Author SHA1 Message Date
c2347281fc Add all slides 2024-07-16 19:29:37 +02:00
3d7526fd3c Random Commit to test Gitea PFP 2024-06-14 22:11:27 +02:00
Matti
7d1af4bd85 Delete works? 2024-05-06 18:32:40 +02:00
Matti
ac503234b2 Delete kinda works except for 1st and 2nd last element 2024-05-06 18:05:13 +02:00
Matti
be8b24140e Delete kinda works 2024-05-06 17:46:02 +02:00
19 changed files with 47 additions and 1 deletions

BIN
Folien/Alle Folien AuD.pdf Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
Folien/AuD_03_Graphen.pdf Normal file

Binary file not shown.

BIN
Folien/AuD_04_Baeume.pdf Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
Folien/AuD_10_Suchen_1.pdf Normal file

Binary file not shown.

BIN
Folien/AuD_11_Suchen_2.pdf Normal file

Binary file not shown.

BIN
Folien/AuD_12_Suchen_3.pdf Normal file

Binary file not shown.

BIN
Folien/AuD_13_Suchen_4.pdf Normal file

Binary file not shown.

BIN
Folien/AuD_14_Codierung.pdf Normal file

Binary file not shown.

Binary file not shown.

View File

@@ -8,6 +8,19 @@ package part1.aufg6;
*/
public class Anwendung {
public static void main(String[] args){
System.out.println("Moin");
LinkedList myList = new LinkedList();
myList.add("a");
myList.add("b");
myList.add("c");
myList.add("d");
// myList.add("e");
// myList.add("f");
myList.delete("a"); // Wird der Speicher der abgekoppelten Zelle freigegeben? Automatisch von JVM?
myList.delete("b");
myList.delete("c");
myList.delete("d");
myList.printALL();
}
}

View File

@@ -33,6 +33,9 @@ public class LinkedList<T>{
}
public void printALL(){ // correct???
if (anchor==null){
return;
}
Cell<T> next = anchor.next;
System.out.println(anchor.data);
@@ -62,4 +65,34 @@ public class LinkedList<T>{
next = next.next; // must happen at end of loop
}
}
public void delete(T value){
System.out.println("Removing " + '"' + value + '"');
if (anchor == null)return;
if (anchor.data == value){
anchor = anchor.next;
return;
}
if ((anchor.next != null) && (anchor.next.data == value)){
anchor.next = anchor.next.next;
}
var cell = anchor.next;
while (cell != null && cell.next != null){
if (cell.next.data == value) {
if (cell.next.next != null) {
cell.next = cell.next.next;
return;
}
}
if ((cell.next.next == null) && (cell.next.data == value)){
cell.next = null;
return;
}
cell = cell.next;
}
}
}