Holonomic equations are recursive equations which allow computing efficiently numbers of combinatoric objects. R{\'e}my showed that the holonomic equation associated with binary trees yields an efficient linear random generator of binary trees. I extend this paradigm to Motzkin trees and Schr{\"o}der trees and show that despite slight differences my algorithm that generates random Schr{\"o}der trees has linear expected complexity and my algorithm that generates Motzkin trees is in O(n) expected complexity, only if we can implement a specific oracle with a O(1) complexity. For Motzkin trees, I propose a solution which works well for realistic values (up to size ten millions) and yields an efficient algorithm.
翻译:完整约束方程是一种递归方程,能够高效计算组合对象的数量。Rémy 证明了与二叉树相关的完整约束方程可产生一种高效的线性随机生成器。本文将该范式扩展至 Motzkin 树和 Schröder 树,并表明:尽管存在细微差异,若能够实现一个复杂度为 O(1) 的特定预言机,则我所提出的随机生成 Schröder 树的算法具有线性期望复杂度,而生成 Motzkin 树的算法亦具有 O(n) 的期望复杂度。针对 Motzkin 树,本文提出一种适用于实际规模(最大可达一千万)的解决方案,并由此得到一个高效算法。