• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

trees

 
Ranch Hand
Posts: 193
Hibernate Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.)
 
Bartender
Posts: 2856
10
Firefox Browser Fedora Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
The moth suit and wings road is much more exciting than taxes. Or this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic