home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!mcsun!sunic!dkuug!daimi!protonen
- From: protonen@daimi.aau.dk (Lars J|dal)
- Newsgroups: comp.programming
- Subject: Re: Why Are Red-Black Trees Obscure?
- Message-ID: <1992Aug27.115551.7958@daimi.aau.dk>
- Date: 27 Aug 92 11:55:51 GMT
- References: <1992Aug26.183817.7371@reed.edu>
- Sender: news@daimi.aau.dk
- Organization: DAIMI: Computer Science Department, Aarhus University, Denmark
- Lines: 27
-
- orpheus@reed.edu (P. Hawthorne) writes:
-
- >Sedgewick, for the chapter on balanced trees in his book "Algorithms," uses
- >the red-black tree. As a data structure, the red-black tree seems simple
- >and well balanced. He convincingly suggests that they are better than AVL
- >trees and yet, I've never seen them mentioned by anyone else. Why not?
-
- >Theus (orpheus@reed.edu)
-
- Probably because the AVL trees are easier to implement. I'm no expert in
- the field, but I have seen the source code for at program using AVL trees.
- The balancing was farely simple, something like "if I have put a new
- element in the biggest part of the current (sub)tree then I should
- rearrange my two subtrees a bit."
- Balancing the red-black trees, on the other hand, involves recognizing
- the near pattern of the tree, including going up the tree and down another
- branch. This means you need a more complicated datastructure (e.g. a list
- of pointers to some nodes above the current), and you need code for
- recognition of all the different patterns. Although the number of such
- patterns is farely small it is bigger than the number of possibilities
- in an AVL tree, and the code needed for each possibility is smaller in
- an AVL tree.
- So, although the red-black tree may seem simple on paper, it is not as
- simple to program. This is probably because humans are much better than
- computers at pattern recognition.
-
- Lars (protonen@daimi.aau.dk)
-