Generic N-ary Tree implementation in Java

I needed a simple implementation of a Generic N-ary tree in Java with some useful utility methods for my work, and to my surprise I couldn’t find a simple library that will do the job. So I went ahead and wrote it myself.

You can find it here: https://github.com/c05mic/GenericN-aryTree . Please “star” the repository if you find it useful. 🙂

Features methods:

  • To check if a node exists in the tree.
  •  To find the total number of nodes in the tree
  • To find the total number of descendants of any node in the tree.
  •  To get all the paths from the root to all the leaves as an ArrayList.
  •  To get the longest path from the root to any leaf.
  •  To get the pre-order/post-order traversal path as an ArrayList.

Contributions are welcome!

Advertisements

2 thoughts on “Generic N-ary Tree implementation in Java

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s