Count trees formed of n nodes
If there are n nodes given ,how many structurally different binary trees can be formed.
Note: You don't have to create trees out of n nodes given ,this is a counting problem.
Note: You don't have to create trees out of n nodes given ,this is a counting problem.
N! (n factorial ) binary trees are possible.
ReplyDelete@gaurav i need someone to write code for this.
ReplyDeleteMore than N!
ReplyDeleteshouldn't it be
ReplyDelete(nC1).1! + (nC2).2! + (nC3).3!.....(nCn).n!
and additional +1 for null tree.
@harpal your count may be correct but can you please write working code for this..
ReplyDelete@harpal: your ans is wrong
ReplyDeleteits a series :
1{for null tree} + 1.n + 2.(n - 1) + 3.(n - 2) + ... n.(n - (n - 1))