What are the total number of possible ordered trees with N nodes?

abhilash_goyal picture abhilash_goyal · Aug 9, 2013 · Viewed 8.1k times · Source

For example for N=3, we can find easily by listing them all, but when asked for any arbitrary N value I am facing problem.

Answer

user1650846 picture user1650846 · Aug 11, 2013

If you are looking at binary trees then, as mcdowella said, Choose(2n,n)/(n+1) (Catalan number) is the answer.

If you are looking at arbitrary trees then it is probably n. n^(n-2) = n^(n-1), but I am not totally sure. Prufer's algo tells us that there are n^(n-2) labeled trees and any of the nodes can be made a root, thus we get the number n^(n-1).