How do you guys print out a binary tree?

bayerj bayerj at in.tum.de
Tue Apr 18 02:56:55 EDT 2006


Hi,

> 1   2   3   4   5
> 0   7   8   9   10
> 0   0   13  14  15
> 0   0   0   19  20
> 0   0   0   0   25
> Look at the triangle represented by the non-zero
> integers.  This triangle is a binary tree if we take 5
> as the root and walk down on both sides.

Are you sure? Is 9  a child of 4 or 10? A binary tree can have up to
2^n - 1 nodes. A matrix can have up to n^2 values, in your case of a
half-empty matrix about (n-1)^2.




More information about the Python-list mailing list