| Newsgroups: net.puzzle,net.math
Path: decwrl!decvax!genrad!mit-eddie!godot!harvard!seismo!brl-tgr!ron
Subject: Re: Questions thrice about binary trees. (SPOILER)
Posted: Tue Nov 20 12:25:14 1984
> Harder question: How many binary trees are there with fifty nodes? (You are
> allowed to use a computer.)
>
> Yet harder question: If B(n) is the number of binary trees with n nodes,
> what is log(B(10,000,000)) to the nearest integer? (Use of a computer is
> highly recommended.)
>
> Note: Consulting a book on combinatorics is considered cheating.
B(50) = 1978261657756160653623774456 I cheated, but Macsyma helps.
If my hasty calculations are correct.
O(log(B(n)) = O(n*log(n))
|
| > How many binary trees are there on 4 nodes?
F(4) = umm, 1*5 + 1*2 + 2*1 + 5*1 = 14
> Harder question: How many binary trees are there with fifty nodes? (You are
> allowed to use a computer.)
$ maple
define(F, forall(integer(n),F(n)=sum(F(k)*F(n-1-k),k=0..n-1)), F(0)=1);
F(50);
1978261657756160653623774456
define(G, forall(integer(n),G(n)=(2*n)!/(n!*(n+1)!)));
F(50)-G(50);
0
See Note 1662.* for proof that F=G.
> Yet harder question: If F(n) is the number of binary trees with n nodes,
> what is log(F(10,000,000)) to the nearest integer? (Use of a computer is
> highly recommended.)
Stirling says:
n! ~ _/(2pi*n)(n/e)^n
So:
log(n!) ~ �log(2pi*n) + n*log(n) - n
log(F(n)) ~ 2n*log2 - (3/2)log(n) - �log(pi)
I forget how accurate Stirling is. But assuming we could neglect other terms
in the approximation, log(F(10^7)) = 13862919, to the nearest integer.
Andrew.
|