Rough Book

random musings of just another computer nerd

Generic (n-ary) Tree in Java

This project is available on github. Please download from there to make sure you have the latest version.

Last week I was solving a problem at work that required the use of a Generic (n-ary) Tree. An n-ary tree is a tree where node can have between 0 and n children. There is a special case of n-ary trees where each node can have at most n nodes (k-ary tree). This implementation focuses on the most general case, where any node can have between 0 and n children. Java doesn’t have a Tree or Tree Node data structure. I couldn’t find any third-party implementations either (like in commons-lang). So I decided to write my own.
Read more »

Popularity: 68% [?]

January 30, 2010 Posted by | Java, Programming and Development | , , , , , , , | 37 Comments

   

All original content on these pages is fingerprinted and certified by Digiprove