【发布时间】:2021-10-31 07:44:12
【问题描述】:
所以我在理解加泰罗尼亚数字概念并尝试使用topDown DP方法在代码中实现它,所以递归关系是我所学的,
f(N) signifies total count of binary search trees possible by N number of nodes
f(N) = f(i-1).f(N-i)
where,
i = 1.....N (i signifies root node and traverse through all the nodes),
N is total number of nodes present in the binary tree,
f(i-1) signifies number of left subtrees possible when i is a root node,
f(N-i) signifies number of right subtrees possible when i is a root node.
有一个数学公式,我们可以通过它找到 f(N) 值,
2NcN/(N+1)
。 并且,N个节点可能的二叉树总数,
(N 的阶乘) * f(N)
我的疑问:
二叉树和二叉搜索树有什么区别?我觉得两者都定义了相同的含义,但是我不知道有一个区别,所以请帮助我。
【问题讨论】:
标签: binary-tree binary-search-tree catalan