suche implementiert
This commit is contained in:
@@ -13,6 +13,10 @@ public class Abschluss extends Baumelement
|
||||
public Baumelement einfügen(Datenelement datenNeu) {
|
||||
return new Knoten(datenNeu);
|
||||
}
|
||||
|
||||
public Datenelement Suche(String suche){
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -5,5 +5,6 @@ public abstract class Baumelement
|
||||
|
||||
// Methoden
|
||||
public abstract Baumelement einfügen(Datenelement datenNeu);
|
||||
public abstract Datenelement Suche(String suche);
|
||||
|
||||
}
|
||||
|
||||
@@ -12,8 +12,12 @@ public class BinBaum
|
||||
this.wurzel = new Abschluss();
|
||||
}
|
||||
|
||||
public void einfügen(Datenelement datenNeu) {
|
||||
this.wurzel = this.wurzel.einfügen(datenNeu);
|
||||
public void einfügen(Datenelement datenNeu_Deu_Eng) {
|
||||
this.wurzel = this.wurzel.einfügen(datenNeu_Deu_Eng);
|
||||
}
|
||||
|
||||
public Datenelement Suche(String suche){
|
||||
return wurzel.Suche(suche);
|
||||
}
|
||||
|
||||
|
||||
|
||||
12
Knoten.java
12
Knoten.java
@@ -30,6 +30,18 @@ public class Knoten extends Baumelement
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public Datenelement Suche(String suche){
|
||||
if (this.daten.gibSchlüssel() == suche) {
|
||||
return daten;
|
||||
} else {
|
||||
if (this.daten.gibSchlüssel().compareTo(suche)>0) {
|
||||
return this.linkerNachfolger.Suche(suche);
|
||||
} else {
|
||||
return this.rechterNachfolger.Suche(suche);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user