Solved

building tree recursively *urgent*

Posted on 2004-04-13
3
202 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
This video teaches viewers about errors in exception handling.
Suggested Courses

710 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