Count the Symmetric Binary Trees

A binary tree is symmetric if the right subtree is a mirror image of the left subtree. For example, there are 9 nodes in the following tree.

How many symmetric binary trees with 11 nodes are there?


The answer is 42.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

1 solution

Ivan Koswara
Oct 20, 2016

Let C n = 1 n + 1 ( 2 n n ) C_n = \frac{1}{n+1} \binom{2n}{n} be the n n -th Catalan number . We claim that the number of symmetric binary trees of 2 n + 1 2n+1 nodes is C n C_n .

First, we need one node as the root. Since the tree is symmetric, constructing the left subtree completely decides the right subtree; just mirror the whole thing. If the left subtree has k k nodes, then so as the right subtree, so the total number of nodes is 2 k + 1 2k+1 . Thus we need k = n k = n .

Now, whatever the left subtree is gives exactly one symmetric tree. So all we need to do is to compute the number of binary trees of n n nodes; this number is equal to the number of symmetric binary trees of 2 n + 1 2n+1 nodes. This number is C n C_n , as proved in the wiki article linked above.

The problem asks for n = 5 n = 5 , thus the answer is C 5 = 1 6 ( 10 5 ) = 42 C_5 = \frac{1}{6} \binom{10}{5} = \boxed{42} .

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...