Question:
A binary is defined as a tree in which 1 vertex is the root, and any other vertex has 2 or 0 children. A vertex with 0 children is called a node, and a vertex with 2 children is called an inner vertex.
The order between the children is important.
A binary tree can be defined with recursion: a binary tree is one out of 2 options :
- A single vertex.
- A vertex in which two sub-trees, that were build before, are connected to him.
Now, let $D_n$ be the number of valid binary trees, >with $n$ inner vertices.
For this question, a binary tree is called $valid$ if for each inner vertex $v$, the left sub-tree connected to $v$ in the left side, contains an even amount (0,2,4,...) of inner vertices.
Find the recursive formula with starting conditions for $D_n$ such that the formula can use all values before. In addition, calculate $D_6$.
$Solution.$ in order to build a valid binary tree of size $n$ we can take all options for a valid binary tree of size $n-1$ and take all options for a valid binary tree of size $n-2$. Therefore, we get: $$D_n=D_{n-1}+D_{n-2}$$
For the starting conditions: we consider $D_1$ which is 1 because we have only the root, which has an even amount of inner vertices (0).
For $D_2$ we have the next tree:
Therefore, $D_2=1$.
Calculation for $D_6$: $$D_6=D_5+D_4=D_4+D_3+D_3+D_2=D_3+D_2+(D_2+D_1)\cdot 2 + D_2=D_2+D_1+D_2+2D_2+2D_1+D_2=5D_2 +3D_1=5+3=8 $$
Now, I am not sure that this is correct, thus, I will be glad for some help. I think that might be better to convert this problem to another problem, but I think that this is good too. Thanks!