Solved

building tree recursively *urgent*

Posted on 2004-04-13
3
193 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
how to see all occupied ports on windows 10 laptop 15 83
Java string replace 11 61
junit as external jar or library 7 37
dao vs facade design patterns 2 31
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…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

763 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