• Post Reply Bookmark Topic Watch Topic
  • New Topic

Recursive Implantation for setting the objects  RSS feed

 
Faraz Ka
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I have a requirement where I have a class as Page which itself contains ArrayList<Page>.
Here ArrayList<Page> is nothing but the pages which are accessible from the base Page.
I know the depth level ( reading from file) which means how many level I need to go to identify more pages.

BUT the problem is how to set the base Page class. I need to set the base Page class but for that I need the objects for the subsequent pages and hence an iterative type of implementation.
I have just started following tree and recursion methods but any other pointer or hint that can help me further is appreciated.

Thanks,
Faraz
 
Faraz Ka
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am implementing it find the complete traversal path starting from base Page to every other page.
So, parent node information is also important and needs to be stored.

Hope I am more clear now.

Regards,
Faraz
 
Darryl Burke
Bartender
Posts: 5167
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is this homework, or are you allowed to use other JDK classes that could make it easier?
 
Faraz Ka
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Darryl,

I guess nothing wrong in using the JDK classes.
Moreover, I this will not be a tree implementation as child node can point back to the parent one.
And one child can have multiple parents as well.

Graph implementation is best suited here.

So, what do you suggest? What will be the implementation steps for this?

Thanks,
Faraz

P.S. I am fairly new to Data Structure and started learning very recently.
 
Darryl Burke
Bartender
Posts: 5167
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Faraz Ka wrote:And one child can have multiple parents as well.


Sorry, that rules out what I was going to suggest (TreeModel and DefaultMutableTreeNode).
 
Faraz Ka
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No worries Darryl. So any other approach that I should be trying?

Regards,
Faraz
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!