Looking for a Java Library That Has Implemented Binary Tree [Closed]
Is There a Java Library That Has Binary Tree That I Can Use? I Am Not Looking Forward to Test and Implement My Own. 4 5 Answers the Java Standard Api Only...
Is there a java library that has Binary Tree that I can use? I am not looking forward to test and implement my own.
5 Answers
The Java standard API only contains libraries that are universally useful and non-trivial to implement. A basic tree is trivial to implement:
class BinaryTree {
BinaryTree left;
BinaryTree right;
Object value;
}
Non-trivial trees are not universally useful: either they are needed as a part of the application data model, which is better modeled using domain specific classes (component has-a list of sub-components), or they are used as a part of a specific algorithm. Algorithms usually require a specific structure from the nodes (e.g. the color or weight of the node needed to maintain the tree balanced), so a generic tree node makes little sense.
What about
A Red-Black tree based NavigableMap implementation. The map is sorted according to the natural ordering of its keys, or by a Comparator provided at map creation time, depending on which constructor is used.
Maybe Swing's TreeModel and its implementation - DefaultTreeModel.
do you mean something like this:
There is a sample implementation on this page here: -around at the bottom half of the page or so-