How do you guys print out a binary tree?

Anthony Liu antonyliu2002 at yahoo.com
Tue Apr 18 11:17:22 EDT 2006



--- bayerj <bayerj at in.tum.de> wrote:

> 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.
> 

Thanks.  I am not concerned about the shape of binary
tree.  So, let's forget about binary tree.  

Given a triangle like that, it does not matter which
is whose children.  How do we nicely present it as
tree in an ascii console?




__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 



More information about the Python-list mailing list