No trees in the stdlib?
tjreedy at udel.edu
Mon Jun 29 21:06:52 CEST 2009
Paul Rubin wrote:
> The idea is you can accomplish the equivalent of insertion or deletion
> by allocating a new root, along with the path down to the place you
> want to insert, i.e. O(log n) operations. So instead of mutating an
> existing tree, you create a new tree that shares most of its structure
> with the old tree, and switch over to using the new tree.
Now I get what your have been talking about over several posts.
Update and mutate are kind of synonymous in my mind, but the above
explains how they can be different.
> trivially lets you maintain snapshots of old versions of the tree,
> implement an "undo" operation, have a background thread do a complex
> operation on a snapshot while the foreground thread does any number of
> update-and-replace operations, etc.
> This is very standard stuff.
Now for someone raised on arrays, iteration, and procedural programming ;-).
Reading it now.
> The wikipedia article on AVL trees makes it pretty obvious how an
> implementation would work.
More information about the Python-list