For a binary tree what is the number of nodes with two children when the number of leaves is 20?
I know that for complete binary tree, when the number of leaves is x then the number of internal nodes is x-1.
But in the question above the given tree is just the binary tree not the complete binary tree. Also, the number of nodes asked is for those having two children which differs from internal node / non-leaf nodes.
Is there any formula to get this?
Let the number of leaves be $l$. Let the number of nodes with exactly two children be $d_2$ and with exactly one children be $d_1$.
Total degree
$d=l+3d_2+2d_1-1$ (as all nodes with 2 children have degree 3 except the root)
Number of nodes $n=d_2+d_1+l$
Number of edges $e=\frac{d}{2}=\frac{l+3d_2+2d_1-1}{2}$
Number of edges in a tree $e=n-1$
$\therefore \frac{l+3d_2+2d_1-1}{2}=d_2+d_1+l-1$
$\therefore d_2=l-1$
This is the result which I was trying to prove in this question.