Looking for a java library that has implemented Binary Tree [closed]

让人想犯罪 __ 提交于 2019-12-03 11:49:00

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 http://docs.oracle.com/javase/6/docs/api/java/util/TreeMap.html

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.

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

http://cslibrary.stanford.edu/110/BinaryTrees.html

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!