• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Recursively Set Tester in a Recursive Tree

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think I need to consider recursive tree traversal over iterative recursive methods.
 
Marshal
Posts: 80226
424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Marshal
Posts: 80226
424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Morning came much too soon and it brought along a friend named Margarita Hangover, and a tiny ad.
New web page for Paul's Rocket Mass Heaters movies
https://coderanch.com/t/785239/web-page-Paul-Rocket-Mass
reply
    Bookmark Topic Watch Topic
  • New Topic