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

For example, for N = 3, we can easily find them by listing them all, but asking for any arbitrary value of N that I encounter is a problem.

+1
source share
4 answers

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

If you look at arbitrary trees, then this is probably n. n ^ (n-2) = n ^ (n-1), but I'm not quite sure. Prufer algo tells us that there are n ^ (n-2) labeled trees, and any of the nodes can be made root, so we get the number n ^ (n-1).

+2
source

This is described in Knuth Vol 1 (The Art of Computer Programming: Fundamental Algorithms). 2.3.4.4. About half of the math page gives you a choice of (2n, n) / (n + 1) and a search for the sequence in Knut finds http://oeis.org/A000108

0
source

, :
fix element i as the root . how many different trees, the first (i-1) elements and the rest (n-i-1) elements.
, (i-1) (n-i-1), :

:

enter image description here

LaTeX:

[] & ; = & ; \sum_ { & ; = & ; 2} ^ { & ; = & , -1} , [I-1] * [-1]

0

(2n, n)/(n + 1) ( ) , n ^ (n-2) .

0

Source: https://habr.com/ru/post/1536769/


All Articles