Re: How do you guys print out a binary tree?

2006-04-19 Thread Anthony Liu
Hi, Bayer Munich, I implemented a syntax parser from bottom up using a CNF grammar. I actually know what part of the triangle of the matrix I need to turn into a tree, but it is kinda hard to describe in text. So, I just made it easy by giving a triangle of the matrix. Anyway, thanks for your h

Re: How do you guys print out a binary tree?

2006-04-19 Thread Anthony Liu
Hi, Dave, That looks nice, I'll definitely try it out. --- Dave Hansen <[EMAIL PROTECTED]> wrote: > On Tue, 18 Apr 2006 08:17:22 -0700 (PDT) in > comp.lang.python, Anthony > Liu <[EMAIL PROTECTED]> wrote: > > > > > > >--- bayerj <[EMAIL PROTECTED]> wrote: > > > >> Hi, > >> > >> > 1 2 3

Re: How do you guys print out a binary tree?

2006-04-19 Thread Dave Hansen
On Tue, 18 Apr 2006 08:17:22 -0700 (PDT) in comp.lang.python, Anthony Liu <[EMAIL PROTECTED]> wrote: > > >--- bayerj <[EMAIL PROTECTED]> 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 trian

Re: How do you guys print out a binary tree?

2006-04-19 Thread bayerj
The problem is that you cannot represent a matrix as a tree, due to the fact that there are more than one tree for a matrix. First you have to decide, how you will turn the matrix into a tree. -- http://mail.python.org/mailman/listinfo/python-list

Re: How do you guys print out a binary tree?

2006-04-18 Thread Anthony Liu
--- bayerj <[EMAIL PROTECTED]> 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 w

Re: How do you guys print out a binary tree?

2006-04-18 Thread bayerj
A half-empty matrix will of course have (n+1)* n * 1/2 elements. -- http://mail.python.org/mailman/listinfo/python-list

Re: How do you guys print out a binary tree?

2006-04-18 Thread bayerj
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

How do you guys print out a binary tree?

2006-04-17 Thread Anthony Liu
There are many ways to represent a binary tree on an ascii screen. 1 / \ 2 3 / \ / \ 4 5 6 7 or 4---2---1 | | 56- 3 | 7 Suppose I have a function that takes a matrix like this one: