简体   繁体   中英

Implementation of Uniform Recursive Tree Java

I was able to find implementations for so many Trees such as,

http://sujitpal.blogspot.com/2006/05/java-data-structure-generic-tree.html

and now I am in search for implementation of Uniform Recursive Tree in Java. This paper explains details on Uniform Recursive Tree. http://www.sciencedirect.com/science/article/pii/S0022247X05004191

Thanks in advance for your help.

This isn't that hard to implement, actually. You basically start with an n-ary tree and all you have to do is figure out how to add a node as a child to one of the existing nodes in the tree.

For a tree with k nodes, a new node k + 1 can become a child of any one of the previous k nodes (ie, any of the nodes in the set {1, 2, ..., k} ).

What you would need is a list of all nodes that currently exist in the tree. I would maintain this is a separate, internal structure within the Tree data-structure. Then you will have to figure out how to select one of the nodes of the tree. This is done by a probability function. I find this part to be a little unclear and that's mostly because I've forgotten a lot of my probability stuff (and I hated probability in school). But the paper does explain how you can compute the probabilities. Essentially you have a series of probability mass functions. So if you have a node 1 , and then a node 2 , node 2 will be attached to node 1 (because there is only one node for 2 to be attached to). A node 3 will be attached to node 1 with a probability of p(2, 1) or to node 2 with a probability of p(2, 2) . What you have to make sure though, is that:

p(k, i) >= 0

and:

sigma(p(k, i)) from i = 1 to k equals 1

A naive implementation would be to simply select one of the nodes randomly out of a list of existing nodes.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM