简体   繁体   中英

Binary Trees Unlabelled Nodes

Number of Binary trees that can be formed using 3 unlabelled nodes.

Answer on several places is 5.

But according to me answer should be 1 because all the trees that we will make using three nodes will be isomorphic.

The number of trees made from n nodes are equal to the nth catalan number .

More precisely here is recursive equation for the trees formed :-

T(n) = sum(T(i)*T(n-1-i)) where i in (0,n-1)

Example :-

consider binary trees of 5 nodes.

  1. keeping one as root we can divide rest 4 into subtrees a follows

    (1,3),(2,2),(3,1) where first tupple is left subtree and 2nd right subtree

  2. You can further have different arrange of the subtrees hence :-

    T(5) = T(1)*T(3) + T(2)*T(2) + T(3)*T(1)

  3. Above method can be generalized to the recurrence relations given above which can be evaluated as catalan numbers using advance mathematics

Your Example : -

 T(3) = T(1)*T(1) + T(2)*T(0) + T(0)*T(2) As T(2) = 2 (1 right aligned & 1 left aligned tree) and T(1) = 1 , T(0) = 1 T(3) = 1*1 + 2*1 + 1*2 = 5 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM