什么是没有。具有 n 个标记节点的不同二叉树的可能性?

What is the no. of distinct binary trees possible with n labeled nodes?

在此 link 中给出:

For a binary tree with n nodes, the no. of edges is n−1. So, this problem can be reduced to the no. of ways in which we can make n−1 edges from n vertices. An edge can be made either as a left child of a node or as a right child. Hence, for n nodes, we have 2n possibilities for the first edge, 2n−1 for the second edge and so on. Thus, for n−1 edges, the total no. of ways

= 2n×(2n−1)×(2n−2)×….×(2n–(n–2))

= 2n×(2n−1)×(2n−2)×….×(n+2)

=(2n)!/(n+1)!

我确实知道第一条边可以有 2n 种可能性,因为对于每个节点都有左右子选项。我想不通第二条边怎么会有 2n-1 种可能性?

n=3时第二条边的可能性是多少?

how second edge can have 2n-1 possibilities?

在您添加第一条边之前,有 2n 种可能性。

添加第一个边后,一个可能性被占用,只剩下2n-1个可能性。

在第二条边之后只剩下 2n-2 种可能,依此类推

对于 n=3,有 6!/4!=30 个变体。只需检查:有 5 个配置,每个配置有 6 个排列:

/\    /     /     \     \
     /      \     /      \