Go Premium for a chance to win a PS4. Enter to Win

x
Solved

# building tree recursively *urgent*

Posted on 2004-04-13
Medium Priority
217 Views
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);
else
int c = max(a,b);
return c;
}

else
{
// creating two nodes...

GameTreeNode child1 = new GameTreeNode(smth);
GameTreeNode child2 = new GameTreeNode(smth);

current_level++;

int temp = buildGameTree(s.getChild(0),d);
int temp2 = buildGameTree(s.getChild(1),d);

//stuck here~

}
}
0
Question by:jtcy
• 2

LVL 9

Accepted Solution

mmuruganandam earned 1000 total points
ID: 10820744
Here is the example,

How do build the tree recursively.

http://www.apl.jhu.edu/~hall/java/Swing-Tutorial/Swing-Tutorial-JTree.html

Regards,
Muruga
0

Author Comment

ID: 10820874
don understand at all
0

LVL 9

Expert Comment

ID: 10820908
Did you have a look on processHierarchy(... method
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
###### Suggested Courses
Course of the Month13 days, 12 hours left to enroll