Re: Memory overhead for trees?
by Paul Rubin other posts by this author
Aug 15 2002 11:48PM messages near this date
Re: How do I access COM object's nondefault interface?
|
Re: Memory overhead for trees?
pinard@[...].ca (François Pinard) writes:
> I'm toying with the idea of converting an existing LISP system into Python.
> The system uses a lot of real trees, I mean, more deep than wide on average.
> Trees are traversed and explored a great deal, but modified relatively less
> often. I'm seeking a representation which, while being reasonably efficient
> -- yet no miracles are expected here! -- is not too voracious on memory.
If it's a binary tree that's reasonably balanced, the usual
representation is a linear array like in the heapsort algorithm.
a[0] is the root; and for any node a[i], the node's children are
a[2*i+1] and a[2*i+2].
--
http://mail.python.org/mailman/listinfo/python-list
Thread:
Paul Rubin
=?iso-8859-1?q?Fran=E7ois?= Pinard
Skip Montanaro
|