aspose file tools*
The moose likes Beginning Java and the fly likes Recursively Set Tester in a Recursive Tree Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Recursively Set Tester in a Recursive Tree" Watch "Recursively Set Tester in a Recursive Tree" New topic
Author

Recursively Set Tester in a Recursive Tree

Nathan Yeung
Greenhorn

Joined: Jun 06, 2009
Posts: 4
Hi Guys,

I'm working on a recursive method that should allow me to set the testers for a Test Group. A test group consists of the tester for the group and a map of test groups. How do I set the tester and then set the map's testers.

I guess I'm confused of how to do a recursive method to set the testers

So here's how structure is organized:

So first you have a selected test plan

Then a test plan has a list of test groups

Each test group can have sub test groups

Now each test group has a tester and a map of test groups.

It's sort of confusing, isn't it?

Currently I'm getting a stack overflow error when I call the method recursively in a for loop that iterates the size of the map of groups of any given test group.
Nathan Yeung
Greenhorn

Joined: Jun 06, 2009
Posts: 4
I think I need to consider recursive tree traversal over iterative recursive methods.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39784
    
  28
Welcome to the Ranch

I think you would do well to get a pencil and paper and large eraser. Draw a diagram of your tree, an dhow you wish to traverse it, and write down how you intend to achieve that. then you can work out the code.

Usually you get overflow errors in recursion if you have failed to ensure each branch has a base case which terminates the recursion. That is worth checking.
Nathan Yeung
Greenhorn

Joined: Jun 06, 2009
Posts: 4
I drew out the tree and realized that I may have a set up a very difficult structure to traverse. I believe that it's doable though I just need some guidance as I am a true Greenhorn here at the ranch. So I am creating a Test Tracker program. I have Test Plans, Test Groups and Test Cases. A test plan consists of a TreeMap of Test Groups and a (sub) test group consists of a TreeMap of test groups and each test group consists of a TreeMap of test cases. Now I would like to traverse this recursive tree structure of test groups to set it's Tester member variable. How do I traverse such a tree structure that contains a TreeMap of test groups?

Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39784
    
  28
Divide and Rule. Work out how to traverse the first tree, and leave the other trees till later. Once you have traversed one, it will be a similar algorithm to traverse the others.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Recursively Set Tester in a Recursive Tree