This commit is contained in:
Azael
2017-03-21 00:17:26 +01:00
parent 9a24fe6356
commit 4e5983b5ce
2 changed files with 13 additions and 10 deletions

View File

@@ -20,14 +20,14 @@ public class Tree {
Node f = new Node(null, fils, null, item, 1+fils.getLvl());
fils.setFather(f);
return f;
} else {
Node filsG = tree(pos+1);
Node filsD = tree(pos+filsG.getLvl()+1);
Node f = new Node(null, filsG, filsD, item, filsG.getLvl() + filsD.getLvl()+1);
filsG.setFather(f);
filsD.setFather(f);
return f;
}
Node filsG = tree(pos+1);
Node filsD = tree(pos+filsG.getLvl());
Node f = new Node(null, filsG, filsD, item, filsG.getLvl() + filsD.getLvl()+1);
filsG.setFather(f);
filsD.setFather(f);
return f;
} else {
return new Node(null, null, null, item, 1);
}
@@ -40,6 +40,7 @@ public class Tree {
private void displayNode(Node n, int lvl){
for (int i = 0; i < lvl; i++)
System.out.print("-");
n.display();
if (n.getLeftChild() != null)
displayNode(n.getLeftChild(),lvl+1);