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

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.

3

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.

1

Maybe Swing's TreeModel and its implementation - DefaultTreeModel.

do you mean something like this:

1

There is a sample implementation on this page here: -around at the bottom half of the page or so-

4
Marcus Vance

Marcus Vance

Cybersecurity & Digital Privacy Researcher

Marcus Vance is a cybersecurity auditor and technology writer dedicated to educating the public about online safety, data privacy regulations, enterprise security, and emerging cyber threats.

Share this article
Twitter Facebook Pinterest