Logo     Photos

16 Member(s) Online

PyCon is a 100%
Volunteer-run
Conference Organized by
Members of the
Python
Community.

Site/Questions etc ?

Valid XHTML 1.0 Transitional

Valid CSS!

 
PyCon 2007 is sponsored
in part by
Zenoss - The Next Step in IT Management Google Microsoft .Net Framework EWT LLC Enthought, Inc.
Platinum
Wingware Python IDE Accense Technology, Inc.
Gold
Quality Vision International Inc. MerchantCircle Big Nerd Ranch, Inc. Canonical
Silver

Details of Talk

#70: Simplifying Red-Black Trees
Author(s):
J Adrian Zimmer / OSSM
Items: audio-no    handouts-no    released-yes    video-no    ADMIN
Abstract:

Ordered binary trees can enable efficient lookup of ordered data. Starting at the root, an algorithm decides whether the desired value has been found or will appear in the left or right subtree. The lookup algorithm proceeds recursively down the tree until it is finds what it wants or is directed to an empty subtree.

Lookup is efficient if the tree is short and fat. Keeping the tree short and fat when doing insertions and deletions is not particularly easy -- if it is to be done efficiently. The red-black tree is one model used to guide this process. Like others it uses a methods of morphing a tree called "rebalancing". Rebalancing involve numerous cases with plenty of symmetry.

This presentation is essentially a case study in one way Python can handle symmetry. The aspect of Python which is most useful to us is its handling of functions as first class objects.

When walking a tree, we want to alter our thinking about nodes. We start thinking about a node as having a left and a right child. After we have walked a node, it has a walked and an unwalked child. We also want to change the way our parent thinks about its children -- not "consciously" but in terms of how that parent would take part in a rotation. In object-oriented terms, we want to change at least one of the parent's methods.

A complete implementation of red-black tree lookup, insertion, and deletion, will be the basis of this presentation. As the title indicates, the implementation emphasizes readability over efficiency but that does not mean it is inefficient. Additional storage is needed only for nodes between the the "current" node and the root. The algorithm does a few more things as it process nodes during a search but not many.

The breakdown of cases need not be different here than for published versions, but it is. Partly this is because the need to distinguish left from right when rebalancing is gone. This means we can remove some subcases based on going different directions in the past two stags. Partly the different case breakdown results from the author's continuing search for a case breakdown that makes beautiful intuitive sense. Whether he is any closer to that goal than what is already published is likely to be a matter of taste.

Item(s):
abstract.stx 01:41:44 2006/02/16 2.2 kB text/html

Note: Talk recordings have come from different donors, with different levels of quality. A suffix has been added to the basename of each recording reflecting this. For eventual upload to a repository like archive.org, a formal naming convention has been followed:

pycon-{date}-{track}-{timeslot}-{talkno}-{donor}.mp3

For those who might prefer a more human-meaningful name, the recordings have MP3/Ogg/Flac ID3 information within and a simple python script could rename your collection to something in a {title}-{author} form.