neue Methoden hizugefügt
This commit is contained in:
@@ -15,8 +15,21 @@ public class Abschluss extends Baumelement
|
||||
}
|
||||
|
||||
public Datenelement Suche(String suche){
|
||||
System.err.println("[404]Not found");
|
||||
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
|
||||
public abstract Baumelement einfügen(Datenelement datenNeu);
|
||||
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
|
||||
{
|
||||
// Attribute
|
||||
@@ -19,6 +20,28 @@ public class BinBaum
|
||||
public Datenelement Suche(String 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
@@ -42,6 +42,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