﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>BlogJava-生活源于奋斗不息 - 不在能知而在能行!!-随笔分类-数据结构及算法</title><link>http://www.blogjava.net/site120/category/18135.html</link><description>&lt;span style="position:relative"&gt;
&lt;span  style="font-size:12px; color:#006699;position:absolute;left:100px; top:10px"&gt;机遇与挑战并存 (&lt;script type="text/javascript" src="http://fastonlineusers.com/on4.php?d=http://www.blogjava.net/site120"&gt;&lt;/script&gt;
)&lt;/span&gt;
&lt;/span&gt;</description><language>zh-cn</language><lastBuildDate>Wed, 28 Feb 2007 02:58:32 GMT</lastBuildDate><pubDate>Wed, 28 Feb 2007 02:58:32 GMT</pubDate><ttl>60</ttl><item><title>[数据结构]-----AVL树(红黑树)</title><link>http://www.blogjava.net/site120/archive/2006/12/06/85888.html</link><dc:creator>姜利阳</dc:creator><author>姜利阳</author><pubDate>Wed, 06 Dec 2006 09:06:00 GMT</pubDate><guid>http://www.blogjava.net/site120/archive/2006/12/06/85888.html</guid><wfw:comment>http://www.blogjava.net/site120/comments/85888.html</wfw:comment><comments>http://www.blogjava.net/site120/archive/2006/12/06/85888.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/site120/comments/commentRss/85888.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/site120/services/trackbacks/85888.html</trackback:ping><description><![CDATA[
		<table width="100%">
				<tbody>
						<tr>
								<td valign="top" align="left" width="100%">
										<table cellspacing="0" cellpadding="0" border="0">
												<tbody>
														<tr>
																<td class="title" valign="baseline">
																		<span class="nowrap">Red-Black Tree</span>
																</td>
														</tr>
														<tr>
																<td valign="top">
																		<span class="nowrap">
																				<img height="3" alt="" src="http://mathworld.wolfram.com/images/entries/underline.gif" width="100%" />
																				<img height="3" alt="" src="http://mathworld.wolfram.com/images/entries/underline.gif" width="20" />
																		</span>
																</td>
																<td>
																		<img height="15" alt="" src="http://mathworld.wolfram.com/images/spacer.gif" />
																</td>
														</tr>
												</tbody>
										</table>
								</td>
						</tr>
						<tr valign="top">
								<td width="100%">
										<a href="http://mathworld.wolfram.com/contact/" target="_blank">
												<img height="25" alt="COMMENT On this Page" src="http://mathworld.wolfram.com/images/entries/comment.gif" width="98" border="0" />
										</a>
										<div align="center">
												<img height="190" alt="RedBlackTree" src="http://mathworld.wolfram.com/images/eps-gif/RedBlackTree_1000.gif" width="157" />
										</div>
										<p class="Text">An extended <a class="Hyperlink" href="http://mathworld.wolfram.com/RootedTree.html">rooted</a><a class="Hyperlink" href="http://mathworld.wolfram.com/BinaryTree.html">binary tree</a> satisfying the following conditions: </p>
										<p class="Item">1. Every node has two <a class="Hyperlink" href="http://mathworld.wolfram.com/Child.html">children</a>, each colored either red or black. </p>
										<p class="Item">2. Every <a class="Hyperlink" href="http://mathworld.wolfram.com/TreeLeaf.html">tree leaf</a> node is colored black. </p>
										<p class="Item">3. Every red node has both of its <a class="Hyperlink" href="http://mathworld.wolfram.com/Child.html">children</a> colored black. </p>
										<p class="Item">4. Every path from the <a class="Hyperlink" href="http://mathworld.wolfram.com/Root.html">root</a> to a <a class="Hyperlink" href="http://mathworld.wolfram.com/TreeLeaf.html">tree leaf</a> contains the same number (the "black-height") of black nodes. </p>
										<p class="Text">Let <img class="inlineformula" height="15" alt="n" src="http://mathworld.wolfram.com/images/equations/Red-BlackTree/inline1.gif" width="7" border="0" /> be the number of internal nodes of a red-black tree. Then the number of red-black trees for <img class="inlineformula" height="15" alt="n==1" src="http://mathworld.wolfram.com/images/equations/Red-BlackTree/inline2.gif" width="33" border="0" />, 2, ... is 2, 2, 3, 8, 14, 20, 35, 64, 122, ... (Sloane's <a class="Hyperlink" href="http://www.research.att.com/~njas/sequences/A001131">A001131</a>). The number of trees with black roots and red roots are given by Sloane's <a class="Hyperlink" href="http://www.research.att.com/~njas/sequences/A001137">A001137</a> and Sloane's <a class="Hyperlink" href="http://www.research.att.com/~njas/sequences/A001138">A001138</a>, respectively. </p>
										<p class="Text">Let<img class="inlineformula" height="15" alt="T_h" src="http://mathworld.wolfram.com/images/equations/Red-BlackTree/inline3.gif" width="15" border="0" />  be the <a class="Hyperlink" href="http://mathworld.wolfram.com/GeneratingFunction.html">generating function</a> for the number of red-black trees of black-height <img class="inlineformula" height="15" alt="h" src="http://mathworld.wolfram.com/images/equations/Red-BlackTree/inline4.gif" width="7" border="0" /> indexed by the number of <a class="Hyperlink" href="http://mathworld.wolfram.com/TreeLeaf.html">tree leaves</a>. Then </p>
										<div>
												<table style="PADDING-LEFT: 50px" cellspacing="0" cellpadding="0" width="100%" align="center">
														<tbody>
																<tr>
																		<td align="left">
																				<img height="19" alt="T_(h+1)(x)==[T_h(x)]^2+[T_h(x)]^4," src="http://mathworld.wolfram.com/images/equations/Red-BlackTree/equation1.gif" width="182" />
																		</td>
																		<td align="right" width="3">
																				<div class="eqnum" id="eqn1">(1) </div>
																		</td>
																</tr>
														</tbody>
												</table>
										</div>
										<p class="Text">where <img class="inlineformula" height="16" alt="T_1(x)==x+x^2" src="http://mathworld.wolfram.com/images/equations/Red-BlackTree/inline5.gif" width="89" border="0" />. If <img class="inlineformula" height="15" alt="T(x)" src="http://mathworld.wolfram.com/images/equations/Red-BlackTree/inline6.gif" width="27" border="0" /> is the <a class="Hyperlink" href="http://mathworld.wolfram.com/GeneratingFunction.html">generating function</a> for the number of red-black trees, then </p>
										<div>
												<table style="PADDING-LEFT: 50px" cellspacing="0" cellpadding="0" width="100%" align="center">
														<tbody>
																<tr>
																		<td align="left">
																				<img height="19" alt="T(x)==x+x^2+T(x^2(1+x)^2)" src="http://mathworld.wolfram.com/images/equations/Red-BlackTree/equation2.gif" width="181" />
																		</td>
																		<td align="right" width="3">
																				<div class="eqnum" id="eqn2">(2) </div>
																		</td>
																</tr>
														</tbody>
												</table>
										</div>
										<p class="Text">(Ruskey). Let <img class="inlineformula" height="15" alt="rb(n)" src="http://mathworld.wolfram.com/images/equations/Red-BlackTree/inline7.gif" width="30" border="0" /> be the number of red-black trees with <img class="inlineformula" height="15" alt="n" src="http://mathworld.wolfram.com/images/equations/Red-BlackTree/inline8.gif" width="7" border="0" /><a class="Hyperlink" href="http://mathworld.wolfram.com/TreeLeaf.html">tree leaves</a>, <img class="inlineformula" height="15" alt="r(n)" src="http://mathworld.wolfram.com/images/equations/Red-BlackTree/inline9.gif" width="23" border="0" /> the number of red-rooted trees, and <img class="inlineformula" height="15" alt="b(n)" src="http://mathworld.wolfram.com/images/equations/Red-BlackTree/inline10.gif" width="25" border="0" /> the number of black-rooted trees. All three of the quantities satisfy the <a class="Hyperlink" href="http://mathworld.wolfram.com/RecurrenceRelation.html">recurrence relation</a></p>
										<div>
												<table style="PADDING-LEFT: 50px" cellspacing="0" cellpadding="0" width="100%" align="center">
														<tbody>
																<tr>
																		<td align="left">
																				<img height="42" alt="R(n)==sum_(n/4&lt;=n&lt;=n/2)(2m; n-2m)R(m)," src="http://mathworld.wolfram.com/images/equations/Red-BlackTree/equation3.gif" width="191" />
																		</td>
																		<td align="right" width="3">
																				<div class="eqnum" id="eqn3">(3) </div>
																		</td>
																</tr>
														</tbody>
												</table>
										</div>
										<p class="Text">where <img class="inlineformula" height="33" alt="(n; k)" src="http://mathworld.wolfram.com/images/equations/Red-BlackTree/inline11.gif" width="23" border="0" /> is a <a class="Hyperlink" href="http://mathworld.wolfram.com/BinomialCoefficient.html">binomial coefficient</a>, <img class="inlineformula" height="15" alt="rb(1)==1" src="http://mathworld.wolfram.com/images/equations/Red-BlackTree/inline12.gif" width="56" border="0" />, <img class="inlineformula" height="15" alt="rb(2)==2" src="http://mathworld.wolfram.com/images/equations/Red-BlackTree/inline13.gif" width="56" border="0" /> for <img class="inlineformula" height="15" alt="R(n)==rb(n)" src="http://mathworld.wolfram.com/images/equations/Red-BlackTree/inline14.gif" width="76" border="0" />, <img class="inlineformula" height="15" alt="r(1)==r(3)==0" src="http://mathworld.wolfram.com/images/equations/Red-BlackTree/inline15.gif" width="90" border="0" />, <img class="inlineformula" height="15" alt="r(2)==1" src="http://mathworld.wolfram.com/images/equations/Red-BlackTree/inline16.gif" width="49" border="0" /> for <img class="inlineformula" height="15" alt="R(n)==r(n)" src="http://mathworld.wolfram.com/images/equations/Red-BlackTree/inline17.gif" width="69" border="0" />, and <img class="inlineformula" height="15" alt="b(1)==1" src="http://mathworld.wolfram.com/images/equations/Red-BlackTree/inline18.gif" width="51" border="0" /> for <img class="inlineformula" height="15" alt="R(n)==b(n)" src="http://mathworld.wolfram.com/images/equations/Red-BlackTree/inline19.gif" width="71" border="0" /> (Ruskey). </p>
										<form name="SearchLinks" action="http://mathworld.wolfram.com/search/" method="post">
												<p class="CrossRefs">
														<span class="crosslinkheader">SEE ALSO:</span>
														<a class="Hyperlink" href="http://mathworld.wolfram.com/B-Tree.html">B-Tree</a>, <a class="Hyperlink" href="http://mathworld.wolfram.com/RootedTree.html">Rooted Tree</a>. <a href="javascript:document.forms.SearchLinks.submit();">[Pages Linking Here]</a></p>
										</form>
								</td>
						</tr>
				</tbody>
		</table>
		<p>1,每个节点有两个子节点,要么是红色要么是黑色<br />2,每个叶节点都为黑色<br />3,每个红节点都有两个黑色的子节点<br />4,从根到叶的每一条路径都包括相同的黑节点.如上图的左边两级,右边有三级<br />根节点的左节点的两个子节点都有黑色,那为什么它不为红色呢?因为它要满足第四点.所以为黑色</p>
<img src ="http://www.blogjava.net/site120/aggbug/85888.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/site120/" target="_blank">姜利阳</a> 2006-12-06 17:06 <a href="http://www.blogjava.net/site120/archive/2006/12/06/85888.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>