home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / programm / 2494 < prev    next >
Encoding:
Internet Message Format  |  1992-08-27  |  1.8 KB

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