<!-- MHonArc v2.4.4 --> <!--X-Subject: [MUD-Dev] Re: Red Black Tree ? --> <!--X-From-R13: "F. Oyrknaqre Bbcvry" <cbcvryNfahtuneobe.pbz> --> <!--X-Date: Fri, 9 Oct 1998 11:08:39 -0700 --> <!--X-Message-Id: 199810091806.LAA09473#cashew,snugharbor.com.snugharbor.com --> <!--X-Content-Type: text/plain --> <!--X-Reference: 361E2BAC.E9C9C8FE#mediacom,it --> <!--X-Head-End--> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"> <html> <head> <title>MUD-Dev message, [MUD-Dev] Re: Red Black Tree ?</title> <!-- meta name="robots" content="noindex,nofollow" --> <link rev="made" href="mailto:popiel#snugharbor,com"> </head> <body background="/backgrounds/paperback.gif" bgcolor="#ffffff" text="#000000" link="#0000FF" alink="#FF0000" vlink="#006000"> <font size="+4" color="#804040"> <strong><em>MUD-Dev<br>mailing list archive</em></strong> </font> <br> [ <a href="../">Other Periods</a> | <a href="../../">Other mailing lists</a> | <a href="/search.php3">Search</a> ] <br clear=all><hr> <!--X-Body-Begin--> <!--X-User-Header--> <!--X-User-Header-End--> <!--X-TopPNI--> Date: [ <a href="msg00135.html">Previous</a> | <a href="msg00137.html">Next</a> ] Thread: [ <a href="msg00135.html">Previous</a> | <a href="msg00141.html">Next</a> ] Index: [ <A HREF="author.html#00136">Author</A> | <A HREF="#00136">Date</A> | <A HREF="thread.html#00136">Thread</A> ] <!--X-TopPNI-End--> <!--X-MsgBody--> <!--X-Subject-Header-Begin--> <H1>[MUD-Dev] Re: Red Black Tree ?</H1> <HR> <!--X-Subject-Header-End--> <!--X-Head-of-Message--> <UL> <LI><em>To</em>: <A HREF="mailto:mud-dev#kanga,nu">mud-dev#kanga,nu</A></LI> <LI><em>Subject</em>: [MUD-Dev] Re: Red Black Tree ? </LI> <LI><em>From</em>: "T. Alexander Popiel" <<A HREF="mailto:popiel#snugharbor,com">popiel#snugharbor,com</A>></LI> <LI><em>Date</em>: Fri, 09 Oct 1998 11:06:39 -0600</LI> <LI><em>cc</em>: <A HREF="mailto:popiel#snugharbor,com">popiel#snugharbor,com</A></LI> <LI><em>Reply-To</em>: <A HREF="mailto:mud-dev#kanga,nu">mud-dev#kanga,nu</A></LI> </UL> <!--X-Head-of-Message-End--> <!--X-Head-Body-Sep-Begin--> <HR> <!--X-Head-Body-Sep-End--> <!--X-Body-of-Message--> <PRE> In message: <<A HREF="msg00135.html">361E2BAC.E9C9C8FE#mediacom,it</A>> Valerio Santinelli <tanis#mediacom,it> writes: > >Can anybody explain me what's a red black tree or just point me to a page >with some docs about it ? There are several pages on the web of fairly uniformly low quality (just search for 'red-black tree'). Here's the beginning of what _Introduction to Algorithms_ by Cormen, Leiserson, and Rivest has to say on the subject: # A red-black tree is a binary search tree with one extra bit of storage per # node: its color, which can be either RED or BLACK. By constraining the # way nodes can be colored on any path from the root to a leaf, red-black # trees ensure that no such path is more than twice as long as any other, # so that the tree is approximately balanced. # # Each node of the tree now contains the fields color, key, left, # right, and p. If a chils or the parent of a node does not exist, # the corresponding pointer field of the node contains the value NIL. # We shall regard these NIL's as being pointers to external nodes (leaves) # of the binary search tree and the normal, key-bearing nodes as being # internal nodes of the tree. # # A binary search tree is a red-black tree if it satisfies the following # red-black properties: # # 1. Every node is either red or black. # 2. Every leaf (NIL) is black. # 3. If a node is red, then both its children are black. # 4. Every simple path from a node to a descendant leaf contains the same # number of black nodes. # # We call the number of black nodes on any path from, but not including, a # node x to a leaf the black-height of the node, denoted bh(x). By property # 4, the notion of black-height is well defined, since all descending # paths from the node have the same number of black nodes. We define the # black-height of a red-black tree to be the black-height of its root. # # The following lemma shows why red-black trees make good search trees. # # Lemma 14.1: A red-black tree with n internal nodes has height at most # 2lg(n+1). [ Proof omitted ] # An immediate consequence of this lemma is that the dynamic-set operations # Search, Minimum, Maximum, Successor, and Predecessor can be implemented # in O(lg n) time on red-black trees, since they can be made to run in # O(h) time on a search tree of height H (as shown in Chapter 13) and any # red-black tree of n nodes is a search tree with height O(lg n). Although # the the algorithms Tree-Insert and Tree-Delete form Chapter 13 run in O(lg # n) time when given a red-black tree as input, they do not directly support # the dynamic-set operations Insert and Delete, since they do not guarantee # that the modified binary search tree will be a red-black tree. We shall # see in Sections 14.3 and 14.4, however, that these two operations can # indeed be supported in O(lg n) time. Enjoy. - Alex </PRE> <!--X-Body-of-Message-End--> <!--X-MsgBody-End--> <!--X-Follow-Ups--> <HR> <!--X-Follow-Ups-End--> <!--X-References--> <UL><LI><STRONG>References</STRONG>: <UL> <LI><STRONG><A NAME="00135" HREF="msg00135.html">[MUD-Dev] Re: Red Black Tree ?</A></STRONG> <UL><LI><EM>From:</EM> Valerio Santinelli <tanis#mediacom,it></LI></UL></LI> </UL></LI></UL> <!--X-References-End--> <!--X-BotPNI--> <UL> <LI>Prev by Date: <STRONG><A HREF="msg00135.html">[MUD-Dev] Re: Red Black Tree ?</A></STRONG> </LI> <LI>Next by Date: <STRONG><A HREF="msg00137.html">[MUD-Dev] Re: Current Projects</A></STRONG> </LI> <LI>Prev by thread: <STRONG><A HREF="msg00135.html">[MUD-Dev] Re: Red Black Tree ?</A></STRONG> </LI> <LI>Next by thread: <STRONG><A HREF="msg00141.html">[MUD-Dev] Re: Red Black Tree ?</A></STRONG> </LI> <LI>Index(es): <UL> <LI><A HREF="index.html#00136"><STRONG>Date</STRONG></A></LI> <LI><A HREF="thread.html#00136"><STRONG>Thread</STRONG></A></LI> </UL> </LI> </UL> <!--X-BotPNI-End--> <!--X-User-Footer--> <!--X-User-Footer-End--> <ul><li>Thread context: <BLOCKQUOTE><UL> <LI><STRONG>[MUD-Dev] Re: Laws of Online World Design</STRONG>, <EM>(continued)</EM> <ul compact> <ul compact> <LI><strong><A NAME="00188" HREF="msg00188.html">[MUD-Dev] Re: Laws of Online World Design</A></strong>, J C Lawrence <a href="mailto:claw#under,engr.sgi.com">claw#under,engr.sgi.com</a>, Tue 13 Oct 1998, 22:14 GMT </LI> </ul> <LI><strong><A NAME="00162" HREF="msg00162.html">[MUD-Dev] Re: Laws of Online World Design</A></strong>, J C Lawrence <a href="mailto:claw#under,engr.sgi.com">claw#under,engr.sgi.com</a>, Tue 13 Oct 1998, 02:45 GMT </LI> <LI><strong><A NAME="00173" HREF="msg00173.html">[MUD-Dev] Re: Laws of Online World Design</A></strong>, Hans-Henrik Staerfeldt <a href="mailto:hhs#cbs,dtu.dk">hhs#cbs,dtu.dk</a>, Tue 13 Oct 1998, 11:28 GMT </LI> </ul> </LI> <LI><strong><A NAME="00135" HREF="msg00135.html">[MUD-Dev] Re: Red Black Tree ?</A></strong>, Valerio Santinelli <a href="mailto:tanis#mediacom,it">tanis#mediacom,it</a>, Fri 09 Oct 1998, 15:29 GMT <UL> <LI><strong><A NAME="00136" HREF="msg00136.html">[MUD-Dev] Re: Red Black Tree ?</A></strong>, T. Alexander Popiel <a href="mailto:popiel#snugharbor,com">popiel#snugharbor,com</a>, Fri 09 Oct 1998, 18:08 GMT </LI> <LI><strong><A NAME="00141" HREF="msg00141.html">[MUD-Dev] Re: Red Black Tree ?</A></strong>, Caliban Tiresias Darklock <a href="mailto:caliban#darklock,com">caliban#darklock,com</a>, Fri 09 Oct 1998, 21:10 GMT <UL> <LI><strong><A NAME="00142" HREF="msg00142.html">[MUD-Dev] Re: Red Black Tree ?</A></strong>, T. Alexander Popiel <a href="mailto:popiel#snugharbor,com">popiel#snugharbor,com</a>, Fri 09 Oct 1998, 21:42 GMT <UL> <LI><strong><A NAME="00143" HREF="msg00143.html">[MUD-Dev] Re: Red Black Tree ?</A></strong>, Caliban Tiresias Darklock <a href="mailto:caliban#darklock,com">caliban#darklock,com</a>, Fri 09 Oct 1998, 23:06 GMT <UL> <LI><strong><A NAME="00144" HREF="msg00144.html">[MUD-Dev] Re: Red Black Tree ?</A></strong>, Ben Greear <a href="mailto:greear#cyberhighway,net">greear#cyberhighway,net</a>, Sat 10 Oct 1998, 06:55 GMT </LI> </UL> </LI> </UL> </LI> </UL> </LI> </UL> </LI> </UL></BLOCKQUOTE> </ul> <hr> <center> [ <a href="../">Other Periods</a> | <a href="../../">Other mailing lists</a> | <a href="/search.php3">Search</a> ] </center> <hr> </body> </html>