Kommentare entfernt + suche implememtiert #1
@@ -15,8 +15,21 @@ public class Abschluss extends Baumelement
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Datenelement Suche(String suche){
|
public Datenelement Suche(String suche){
|
||||||
|
System.err.println("[404]Not found");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
public int HöheGeben(){
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean IstVorhanden(String Testwort){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int TiefeGeben(String suche){
|
||||||
|
System.err.println("[404]Not found");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -6,5 +6,7 @@ public abstract class Baumelement
|
|||||||
// Methoden
|
// Methoden
|
||||||
public abstract Baumelement einfügen(Datenelement datenNeu);
|
public abstract Baumelement einfügen(Datenelement datenNeu);
|
||||||
public abstract Datenelement Suche(String suche);
|
public abstract Datenelement Suche(String suche);
|
||||||
|
public abstract int HöheGeben();
|
||||||
|
public abstract boolean IstVorhanden(String IstVorhanden);
|
||||||
|
public abstract int TiefeGeben(String suche);
|
||||||
}
|
}
|
||||||
|
|||||||
23
BinBaum.java
23
BinBaum.java
@@ -1,4 +1,5 @@
|
|||||||
|
|
||||||
|
|
||||||
public class BinBaum
|
public class BinBaum
|
||||||
{
|
{
|
||||||
// Attribute
|
// Attribute
|
||||||
@@ -20,6 +21,28 @@ public class BinBaum
|
|||||||
return wurzel.Suche(suche);
|
return wurzel.Suche(suche);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int HöheGeben(){
|
||||||
|
return wurzel.HöheGeben()-1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean IstVorhanden(String Testwort){
|
||||||
|
return wurzel.IstVorhanden(Testwort);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int TiefeGeben(String suche){
|
||||||
|
return wurzel.TiefeGeben(suche);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public void TestwerteEinfügen(){
|
||||||
|
einfügen(new Wortpaar("test","test"));
|
||||||
|
einfügen(new Wortpaar("hallo","hello"));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
29
Knoten.java
29
Knoten.java
@@ -43,6 +43,35 @@ public class Knoten extends Baumelement
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int HöheGeben(){
|
||||||
|
if (linkerNachfolger.HöheGeben() > rechterNachfolger.HöheGeben()){
|
||||||
|
return linkerNachfolger.HöheGeben()+1;
|
||||||
|
}
|
||||||
|
return rechterNachfolger.HöheGeben()+1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean IstVorhanden(String Testwort){
|
||||||
|
if(daten.gibSchlüssel().equals(Testwort)){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (this.daten.gibSchlüssel().compareTo(Testwort)>0) {
|
||||||
|
return this.linkerNachfolger.IstVorhanden(Testwort);
|
||||||
|
} else {
|
||||||
|
return this.rechterNachfolger.IstVorhanden(Testwort);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int TiefeGeben(String suche){
|
||||||
|
if(daten.gibSchlüssel().equals(suche)){
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (this.daten.gibSchlüssel().compareTo(suche)>0) {
|
||||||
|
return this.linkerNachfolger.TiefeGeben(suche)+1;
|
||||||
|
} else {
|
||||||
|
return this.rechterNachfolger.TiefeGeben(suche);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user