• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

trees

 
Higgledy Smith
Ranch Hand
Posts: 192
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to understand how to program a solution in trees. Somehow my gets lost between tree theory and applying that theory in code.

Does anyone have (or know a site) to a tree problem that I can use to learn programming trees, preferably a Java solution?

Thanks
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would start by googling for java tree sample code. (Note: When I tried it, the first site that came up was roseindia. Avoid that site. It's riddled with errors.)
 
Amit Ghorpade
Bartender
Posts: 2854
10
Fedora Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What particular tree are you trying to program?

There are many types of trees in programming, I am assuming that you are talking of a plain old binary tree.
I was thinking of the program and recalled the days when I was learning data structures for the first time
Its fun.
To start with, a tree node looks something like the following code.



Constructing tree is not much tricky as tree traversal is ;).

P.S The above quick code is inspired from my C/C++ way of doing it. There can be better way of doing it in Java.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic