building tree recursively *urgent*
Posted on 2004-04-13
Can someone helps me to write a method that can produce a tree recursively? Has a branching factor of 2, and has a depth of 3. It should push the maximum value of both at depth 3 to its upper level, and the upper level pushes the minimum ones upper and the root decides the maximum value. I have done smth like: But it doesnt work. Can someone help???
int buildGameTree(GameTreeNode s)
if (current_level == 3)
int a = evaluate(s.getChildAt(0);
int b = evaluate(s.getChildAt(1);
if (current_level == 1)
int c = min(a,b);
int c = max(a,b);
// creating two nodes...
GameTreeNode child1 = new GameTreeNode(smth);
GameTreeNode child2 = new GameTreeNode(smth);
int temp = buildGameTree(s.getChild(0),d);
int temp2 = buildGameTree(s.getChild(1),d);