Inspired by [4] we present a new algorithm for uniformly random generation of ordered trees in which all occuring outdegrees can be specified by a given sequence of numbers. The method can be used for random generation of binary or n-ary trees, or ones with various arities. We show that the algorithm is correct and has $O(n)$ time complexity for $n$ being the desired number of nodes in the resulting tree. In the discussion part we show how some selected formulas can be derived with the use of ideas developed in the proof of correctness of the algorithm.
翻译:受 [ 4] 启发, 我们提出了一个新的算法, 用于随机随机生成定购的树木, 其中所有发生的情况都可以由一定数量序列来指定。 该方法可用于随机生成二进制或n- ary 树, 或具有各种异常的树。 我们显示算法是正确的, 并具有$(n) 时间复杂性, $( n) 是结果树中想要的节点数 。 在讨论部分中, 我们展示了如何使用在算法正确性证明中形成的想法来生成某些选定的公式 。