Solved

building tree recursively *urgent*

Posted on 2004-04-13
3
182 Views
Last Modified: 2010-03-31
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);
            
                  aNode.addChild(child1);
                  aNode.addChild(child2);
                  
                  current_level++;
                  
                  int temp = buildGameTree(s.getChild(0),d);
                  int temp2 = buildGameTree(s.getChild(1),d);
                  
                  //stuck here~
                  
     }
}
0
Comment
Question by:jtcy
  • 2
3 Comments
 
LVL 9

Accepted Solution

by:
mmuruganandam earned 500 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

by:jtcy
ID: 10820874
don understand at all
0
 
LVL 9

Expert Comment

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

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
login jsp example 24 49
Configure a Bean in an XML file 4 31
null output 3 25
login form jsp example 2 25
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
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 …
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
This video teaches viewers about errors in exception handling.

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question