develooper Front page | perl.fwp | Postings from September 2001

Re: binary trees in arrays

Thread Previous | Thread Next
From:
David L. Nicol
Date:
September 6, 2001 04:35
Subject:
Re: binary trees in arrays
Message ID:
3B975E0B.76DA5E82@kasey.umkc.edu
Ariel Scolnicov wrote:
 
> This only works for complete binary trees, of course.  You cannot
> e.g. represent this tree (without wasting an exponential amount of
> space, that it):
> 
>                          /\
>                         /\
>                        /\
>                       /\
>                      /\
>                     /\
>                    /\
>                   /\
> 
> So it's mostly used for very specific trees.  There's a standard way
> to build a heap which works this way.


Hashes also waste a lot of space.  Something balanced might use less
space than a hash.  Depends on the data, of course.





-- 
                                           David Nicol 816.235.1187
Refuse to take new work - finish existing work - shut down.

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About