• Post Reply Bookmark Topic Watch Topic
  • New Topic

Java reading from text file passing code?  RSS feed

 
Alan Hollis
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey folks another question for you lot...

Basically i have a binary tree which im setting up at the moment like this



I wanna do this differently so that the tree is more dynamic. The only way i can think of doing it is having these commands in a text file and then updating it when some one wants to add another node... Is this possible?
 
M Beck
Ranch Hand
Posts: 323
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i suppose it's possible, but:

- you'll have to decide on a format for the text file. this format must:
* express what a "node" is
* express which node is "parent" and which is "child"
* most likely express which child is "left" and which is "right"
- after that, you'll have to write code to read this text file, decode it, and construct your tree accordingly.

sounds like a fun little exercise, actually. if you choose to do it, keep us updated on how it goes, and we'll be happy to help you out with any problems that might pop up.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!