M
MrWulf
Gast
Code:
import java.util.Random;;
public class IntTree {
int key;
IntTree left=null;
IntTree right=null;
int h=0; //die aktuelle Höhe
public IntTree(int k){
key=k;
h++;
}
public void insert(int k){
int tmp=this.key;
IntTree tmpleft=this.left;
IntTree tmpright=this.right;
IntTree element= new IntTree(k);
if(element.key < tmp){
tmpleft=element;
if(element.key > tmp){
tmpright=element;
}
}
}
public int height(){
return h;
}
public static void main(){
IntTree wurzel=new IntTree(1);
Random rnd=new Random();
for(int i=0; i<=10; i++){
int tmp=rnd.nextInt(10);
wurzel.insert(tmp);
}
System.out.println(wurzel.height());
}
}
eclipse meint "selection does not contain a main type" obwohl da ja einer vorhanden ist...
kann mir jemand helfen?