如何在 python 中生成随机树。我有一个数组,我想从中生成一棵随机树。我有以下代码:
class Testcase(object):
def generateRandomTree(depth, p):
'''
depth = max length of path
p = probability for another child on one level
'''
raise NotImplementedError()
def main():
t = Testcase();
t.generateRandomTree(3, 0.4)
main()
谁能告诉我如何生成随机树?