The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
+16 votes
1.9k views

The maximum number of binary trees that can be formed with three unlabeled nodes is:

  1. $1$
  2. $5$
  3. $4$
  4. $3$
asked in DS by Veteran (69k points)
edited by | 1.9k views
For unlabelled tree
   T(n) = (2n)! / (n+1)!n!
Number of Labeled Tees = (Number of unlabeled trees) * n!
                       = [(2n)! / (n+1)!n!]  × n!

 

Useful read

https://www.geeksforgeeks.org/enumeration-of-binary-trees/

3 Answers

+20 votes
Best answer

can be found with formula... $(2nCn/n+1)$... $n$ being the number of nodes. for the given question... where $n=3$... answer is $5$. Let me also specify here.. that number of Binary Search Trees with $n$ nodes is equal to number of unlabeled Binary trees.

http://gatecse.in/wiki/Number_of_Binary_trees_possible_with_n_nodes

 

answered by Veteran (19.8k points)
edited by
What if it is labeled
if its labeled, then since its only a binary tree and not BST, we multiply it with 3! (n! for n nodes)
If it was BST then it would be still 5 even if it is labeled , is it not @ryan sequeira ?

correct me if wrong .
yes, in case of BST the nodes can have only one arrangement, i.e sorted order
In Unlabeled tree's only structure matters, what's value in node that does not matter.
1. o      2.    o       3.   o      4.    o   5.    o
      \               \           / \           /          /
       o               o       o   o      o          o  
      /                   \                  /              \
   o                      o              o                 o
With three unlabeled node, there are 5 trees. If they were labeled, then each strucure can be filled with 3! ways.
Yes it's okay to do it with formula but we can also do this by using permutation and combination and just by visualising and analysing as numbe of node is 3. it willbe 5.
0 votes
There are 5 binary trees maximum
answered by Veteran (14.3k points)


Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true

33,646 questions
40,193 answers
114,176 comments
38,664 users