Solved

building tree recursively *urgent*

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
base64 decode encode 12 122
Checkbox and ListView in Android Layout 4 56
servlet doXXX methods 3 39
varialbe initialization 11 30
For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
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 …
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
This video teaches viewers about errors in exception handling.

864 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now