﻿<?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>C++博客-绿-文章分类-数据结构</title><link>http://www.cppblog.com/chxzwj/category/17970.html</link><description>希望，是美好的……</description><language>zh-cn</language><lastBuildDate>Wed, 21 Dec 2011 13:35:54 GMT</lastBuildDate><pubDate>Wed, 21 Dec 2011 13:35:54 GMT</pubDate><ttl>60</ttl><item><title>查找</title><link>http://www.cppblog.com/chxzwj/articles/161843.html</link><dc:creator>chxzwj</dc:creator><author>chxzwj</author><pubDate>Fri, 09 Dec 2011 13:34:00 GMT</pubDate><guid>http://www.cppblog.com/chxzwj/articles/161843.html</guid><wfw:comment>http://www.cppblog.com/chxzwj/comments/161843.html</wfw:comment><comments>http://www.cppblog.com/chxzwj/articles/161843.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/chxzwj/comments/commentRss/161843.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/chxzwj/services/trackbacks/161843.html</trackback:ping><description><![CDATA[<p><span style="font-family: 'Times New Roman'; font-size: 10.5pt">1.&nbsp;</span><span style="font-family: '宋体'; font-size: 10.5pt">查找的基本概念</span><span style="font-family: 'Times New Roman'; font-size: 10.5pt"></span></p>
<div style="layout-grid:  15.6pt none">
<p style="margin-top: 0pt; text-indent: 21pt; margin-bottom: 0pt; margin-left: 21pt"><span style="font-family: '宋体'; font-size: 10.5pt">衡量一个查找算法的时间效率的标准是：在查找过程中，关键字的平均次数，这个标准为平均查找长度</span><span style="font-family: '宋体'; font-size: 10.5pt">ASL；</span></p>
<p style="margin-top: 0pt; text-indent: -21.25pt; margin-bottom: 0pt; margin-left: 21.25pt"><span style="font-family: 'Times New Roman'; font-size: 10.5pt">2.&nbsp;</span><span style="font-family: '宋体'; font-size: 10.5pt">顺序查找法</span></p>
<p style="margin-top: 0pt; text-indent: -21.25pt; margin-bottom: 0pt; margin-left: 42.25pt"><span style="font-family: 'Times New Roman'; font-size: 10.5pt">1)&nbsp;</span><span style="font-family: '宋体'; font-size: 10.5pt">在顺序表上的查找（非等概率查找）</span><span style="font-family: '宋体'; font-size: 10.5pt">:若等概率，则平均ASL为（n+1）/2;若非等概率，则求出期望</span></p>
<p style="margin-top: 0pt; text-indent: -21.25pt; margin-bottom: 0pt; margin-left: 42.25pt"><span style="font-family: 'Times New Roman'; font-size: 10.5pt">2)&nbsp;</span><span style="font-family: '宋体'; font-size: 10.5pt">在线性链表上的查找</span></p>
<p style="margin-top: 0pt; text-indent: -21.25pt; margin-bottom: 0pt; margin-left: 21.25pt"><span style="font-family: 'Times New Roman'; font-size: 10.5pt">3.&nbsp;</span><span style="font-family: '宋体'; font-size: 10.5pt">折半查找</span></p>
<p style="text-align: justify; margin-top: 0pt; text-indent: -21.25pt; margin-bottom: 0pt; margin-left: 42.25pt"><span style="font-family: 'Times New Roman'; font-size: 10.5pt">1)&nbsp;</span><span style="font-family: '宋体'; font-size: 10.5pt">折半查找过程，关键序列有序，则二叉排序树一定，即判定树。</span></p>
<p style="text-align: justify; margin-top: 0pt; text-indent: -21.25pt; margin-bottom: 0pt; margin-left: 42.25pt"><span style="font-family: 'Times New Roman'; font-size: 10.5pt">2)&nbsp;</span><span style="font-family: '宋体'; font-size: 10.5pt">若是关键码无序，仍可构造二叉排序树，进而计算每个关键码的平均ASL。</span></p>
<p style="text-align: justify; margin-top: 0pt; text-indent: -21.25pt; margin-bottom: 0pt; margin-left: 42.25pt"><span style="font-family: 'Times New Roman'; font-size: 10.5pt">3)&nbsp;</span><span style="font-family: '宋体'; font-size: 10.5pt">若是关键码无序，仍可构造二叉排序树，建立过程中，可以调整为平衡二叉树。进而计算每个关键码的平均ASL。</span></p>
<p style="margin-top: 0pt; text-indent: -21.25pt; margin-bottom: 0pt; margin-left: 21.25pt"><span style="font-family: 'Times New Roman'; font-size: 10.5pt">4.&nbsp;</span><span style="font-family: '宋体'; font-size: 10.5pt">B树</span></p>
<p style="margin-top: 0pt; text-indent: -21.25pt; margin-bottom: 0pt; margin-left: 42.25pt"><span style="font-family: 'Times New Roman'; font-size: 10.5pt">1)&nbsp;</span><span style="font-family: '宋体'; font-size: 10.5pt">线性索引：所有子表，分块有序，后一个子表的所有关键字大于前面一个子表中所有元素的关键字。另外，在建立一张索引表，索引项记录了各子表的最大关键值以及所在的位置，因此，各个索引项在索引表中的序号与各个子表的块号一一对应。对索引顺序结构进行查找时，分为两级查找。先通过索引项确定子表，然后在子表中查找。</span></p>
<p style="margin-top: 0pt; text-indent: -21.25pt; margin-bottom: 0pt; margin-left: 42.25pt"><span style="font-family: 'Times New Roman'; font-size: 10.5pt">2)&nbsp;</span><span style="font-family: '宋体'; font-size: 10.5pt">多级索引和</span><span style="font-family: '宋体'; font-size: 10.5pt">m叉查找树：有多级索引构成一个m叉查找树，树中的每一个分支节点表示索引块，他最多存放m个索引块，每个索引块分别给出各子树节点的最大关键字和节点地址。</span></p>
<p style="margin-top: 0pt; text-indent: -21.25pt; margin-bottom: 0pt; margin-left: 42.25pt"><span style="font-family: 'Times New Roman'; font-size: 10.5pt">3)&nbsp;</span><span style="font-family: '宋体'; font-size: 10.5pt">B树为二叉排序树</span></p>
<p style="margin-top: 0pt; text-indent: -21.25pt; margin-bottom: 0pt; margin-left: 42.25pt"><span style="font-family: 'Times New Roman'; font-size: 10.5pt">4)&nbsp;</span><span style="font-family: '宋体'; font-size: 10.5pt">B-树的概念：根节点至少有2个子树；非根的非中终端接点有m/2个结点；含有k个结点的子树种有k-1个关键字。</span></p>
<p style="margin-top: 0pt; text-indent: -21.25pt; margin-bottom: 0pt; margin-left: 42.25pt"><span style="font-family: 'Times New Roman'; font-size: 10.5pt">5)&nbsp;</span><span style="font-family: '宋体'; font-size: 10.5pt">B+树的概念：B+树是-B的一种变形，它与B树的区别在于有k个关键字的结点必然有K棵子树，非叶子结点仅仅具有索引作用，而跟记录有关的关键字都在叶子结点中。</span><span style="font-family: '宋体'; font-size: 10.5pt">跟B树的查找类似，但是也有不同。由于跟记录有关的信息存放在叶结点中，查找时若在上层已找到待查的关键码，并不停止，而是继续沿指针向下一直查到叶结点层的关键码。此外，B+树的所有叶结点构成一个有序链表，可以按照关键码排序的次序遍历全部记录。上面两种方式结合起来，使得B+树非常适合范围检索。</span></p>
<p style="margin-top: 0pt; text-indent: -21.25pt; margin-bottom: 0pt; margin-left: 21.25pt"><span style="font-family: 'Times New Roman'; font-size: 10.5pt">5.&nbsp;</span><span style="font-family: '宋体'; font-size: 10.5pt">散列查找</span></p>
<p style="margin-top: 0pt; text-indent: -21.25pt; margin-bottom: 0pt; margin-left: 42.25pt"><span style="font-family: 'Times New Roman'; font-size: 10.5pt">1)&nbsp;</span><span style="font-family: '宋体'; font-size: 10.5pt">散列表的概念</span><span style="font-family: '宋体'; font-size: 10.5pt">:表项的存储位置与表项关键字之间确立一个对应的关系函数。</span></p>
<p style="margin-top: 0pt; text-indent: -21.25pt; margin-bottom: 0pt; margin-left: 42.25pt"><span style="font-family: 'Times New Roman'; font-size: 10.5pt">2)&nbsp;</span><span style="font-family: '宋体'; font-size: 10.5pt">常见散列函数：除留余数法。</span></p>
<p style="margin-top: 0pt; text-indent: -21.25pt; margin-bottom: 0pt; margin-left: 42.25pt"><span style="font-family: 'Times New Roman'; font-size: 10.5pt">3)&nbsp;</span><span style="font-family: '宋体'; font-size: 10.5pt">解决冲突的方法：线性探测法，二次探测法，拉链法</span></p>
<p style="margin-top: 0pt; text-indent: -21.25pt; margin-bottom: 0pt; margin-left: 42.25pt"><span style="font-family: 'Times New Roman'; font-size: 10.5pt">4)&nbsp;</span><span style="font-family: '宋体'; font-size: 10.5pt">效率分析：查找成功的平均查找长度；查找失败的平均查找长度；</span></p>
<p style="margin-top: 0pt; margin-bottom: 0pt; margin-left: 21pt"></p></div>
<p><!--EndFragment--></p><img src ="http://www.cppblog.com/chxzwj/aggbug/161843.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/chxzwj/" target="_blank">chxzwj</a> 2011-12-09 21:34 <a href="http://www.cppblog.com/chxzwj/articles/161843.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>栈和队列</title><link>http://www.cppblog.com/chxzwj/articles/159099.html</link><dc:creator>chxzwj</dc:creator><author>chxzwj</author><pubDate>Wed, 26 Oct 2011 03:16:00 GMT</pubDate><guid>http://www.cppblog.com/chxzwj/articles/159099.html</guid><wfw:comment>http://www.cppblog.com/chxzwj/comments/159099.html</wfw:comment><comments>http://www.cppblog.com/chxzwj/articles/159099.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/chxzwj/comments/commentRss/159099.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/chxzwj/services/trackbacks/159099.html</trackback:ping><description><![CDATA[<div><div><p style="margin-left:21.2500pt; text-indent:-21.2500pt; margin-bottom:0pt; margin-top:0pt; "><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Times New Roman'; "></span></p><div><div><p style="margin-left:21.2500pt; text-indent:-21.2500pt; margin-bottom:0pt; margin-top:0pt; "><font class="Apple-style-span" face="'Times New Roman'"></font></p><div><p style="margin-left:21.2500pt; text-indent:-21.2500pt; margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; "><font class="Apple-style-span" face="'Times New Roman'"><span style=" font-size:10.5000pt; font-family:'Times New Roman'; ">1.&nbsp;</span><span style=" font-size:10.5000pt; font-family:'宋体'; ">栈和队列的概念</span></font></p><p style="margin-left:42.2500pt; text-indent:-21.2500pt; margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; "><font class="Apple-style-span" face="'Times New Roman'"><span style=" font-size:10.5000pt; font-family:'Times New Roman'; ">1)&nbsp;</span><span style=" font-size:10.5000pt; font-family:'宋体'; ">栈:只允许一端进行插入和删除的线性表;允许插入和删除的一端叫做栈顶;不允许插入和删除的一端叫做栈底.先进后出</span></font></p><p style="margin-left:42.2500pt; text-indent:-21.2500pt; margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; "><font class="Apple-style-span" face="'Times New Roman'"><span style=" font-size:10.5000pt; font-family:'Times New Roman'; ">2)&nbsp;</span><span style=" font-size:10.5000pt; font-family:'宋体'; ">队列:允许插入的一端为队首,允许删除的一端为队尾.先进先出</span></font></p><p style="margin-left:21.2500pt; text-indent:-21.2500pt; margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; "><font class="Apple-style-span" face="'Times New Roman'"><span style=" font-size:10.5000pt; font-family:'Times New Roman'; ">2.&nbsp;</span><span style=" font-size:10.5000pt; font-family:'宋体'; ">存储结构</span></font></p><p style="margin-left:42.2500pt; text-indent:-21.2500pt; margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; "><font class="Apple-style-span" face="'Times New Roman'"><span style=" font-size:10.5000pt; font-family:'Times New Roman'; ">1)&nbsp;</span><span style=" font-size:10.5000pt; font-family:'宋体'; ">栈的顺序存储结构:结构体,有数组和顶指针</span></font></p><p style="margin-left:42.2500pt; text-indent:-21.2500pt; margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; "><font class="Apple-style-span" face="'Times New Roman'"><span style=" font-size:10.5000pt; font-family:'Times New Roman'; ">2)&nbsp;</span><span style=" font-size:10.5000pt; font-family:'宋体'; ">栈的链式存储结构:单链表</span></font></p><p style="margin-left:42.2500pt; text-indent:-21.2500pt; margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; "><font class="Apple-style-span" face="'Times New Roman'"><span style=" font-size:10.5000pt; font-family:'Times New Roman'; ">3)&nbsp;</span><span style=" font-size:10.5000pt; font-family:'宋体'; ">队列的顺序存储结构:结构体,数组,首尾指针</span></font></p><p style="margin-left:42.2500pt; text-indent:-21.2500pt; margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; "><font class="Apple-style-span" face="'Times New Roman'"><span style=" font-size:10.5000pt; font-family:'Times New Roman'; ">4)&nbsp;</span><span style=" font-size:10.5000pt; font-family:'宋体'; ">队列的链式存储结构:单链表.</span></font></p><p style="margin-left:42.2500pt; text-indent:-21.2500pt; margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; "><font class="Apple-style-span" face="'Times New Roman'"><span style=" font-size:10.5000pt; font-family:'Times New Roman'; ">5)&nbsp;循环队列：队列为空时：rear==front；队列满时：(rear+1)%maxSize&nbsp;=&nbsp;front.（牺牲了一个存储空间单元）</span></font></p><p style="margin-left:21.2500pt; text-indent:-21.2500pt; margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; "><font class="Apple-style-span" face="'Times New Roman'"><span style=" font-size:10.5000pt; font-family:'Times New Roman'; ">3.&nbsp;</span><span style=" font-size:10.5000pt; font-family:'宋体'; ">应用</span></font></p><p style="margin-left:42.2500pt; text-indent:-21.2500pt; margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; "><font class="Apple-style-span" face="'Times New Roman'"><span style=" font-size:10.5000pt; font-family:'Times New Roman'; ">1)&nbsp;</span><span style=" font-size:10.5000pt; font-family:'宋体'; ">栈在表达式中的应用</span></font></p><p style="margin-left:21.0000pt; text-indent:20.0000pt; margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; "><font class="Apple-style-span" face="'Times New Roman'"><span style=" font-size:10.5000pt; font-family:'宋体'; ">&#9312;　前缀表达式:(A+B)*C----&gt;*C+AB</span><span style=" color:#000000; font-style:normal; font-size:10.5000pt; font-family:'Arial'; ">　</span>&nbsp;<span style=" font-size:10.5000pt; font-family:'宋体'; ">(波兰式);(运算符在前,从右到左扫描)</span></font></p><p style="margin-left:21.0000pt; text-indent:20.0000pt; margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; "><font class="Apple-style-span" face="'Times New Roman'"><span style=" font-size:10.5000pt; font-family:'宋体'; ">&#9313;　后缀表达式:(A+B)*C------&gt;AB+C*.(运算符在后，从左到有扫描)</span></font></p><p style="margin-left:42.2500pt; text-indent:-21.2500pt; margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; "><font class="Apple-style-span" face="'Times New Roman'"><span style=" font-size:10.5000pt; font-family:'Times New Roman'; ">2)&nbsp;</span><span style=" font-size:10.5000pt; font-family:'宋体'; ">栈递归中的应用</span></font></p><p style="margin-left:42.2500pt; text-indent:-21.2500pt; margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; "><font class="Apple-style-span" face="'Times New Roman'"><span style=" font-size:10.5000pt; font-family:'Times New Roman'; ">3)&nbsp;</span><span style=" font-size:10.5000pt; font-family:'宋体'; ">使用队列主要是为了保存下一步的处理步骤</span></font></p><p style="margin-left:42.2500pt; text-indent:-21.2500pt; margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; "><font class="Apple-style-span" face="'Times New Roman'"><span style=" font-size:10.5000pt; font-family:'Times New Roman'; ">4)&nbsp;</span><span style=" font-size:10.5000pt; font-family:'宋体'; ">特殊矩阵的压缩存储</span></font></p><p style="margin-left:21.0000pt; text-indent:20.0000pt; margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; "><font class="Apple-style-span" face="'Times New Roman'"><span style=" font-size:10.5000pt; font-family:'宋体'; ">&#9312;　二维数组对于二维矩阵对应，数组的下标对应矩阵的下标A[m][n];</span></font></p><p style="margin-left:21.0000pt; text-indent:20.0000pt; margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; "><font class="Apple-style-span" face="'Times New Roman'"><span style=" font-size:10.5000pt; font-family:'宋体'; ">&#9313;　二维矩阵的行优先存储，a[i][j]对应的存储位置为loc（0，0）+（i*m+j）*L</span></font></p><p style="margin-left:21.0000pt; text-indent:20.0000pt; margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; "><font class="Apple-style-span" face="'Times New Roman'"><span style=" font-size:10.5000pt; font-family:'宋体'; ">&#9314;　下三角矩阵行优先存储：a[i,j]在数组B中的存储位置为1+2+3+&#8230;&#8230;+i+j</span></font></p><p style="margin-left:21.0000pt; text-indent:20.0000pt; margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; "><font class="Apple-style-span" face="'Times New Roman'"><span style=" font-size:10.5000pt; font-family:'宋体'; ">&#9315;　上三角矩阵行优先存储：a[i,j]在数组B中的存储位置为n+&#8230;&#8230;+（n+1-i）+j-i；</span></font></p><p style="margin-bottom:0pt; margin-top:0pt; "></p></div><p>&nbsp;</p></div></div><p style="margin-left:42.2500pt; text-indent:-21.2500pt; margin-bottom:0pt; margin-top:0pt; "><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体'; "></span></p></div></div><img src ="http://www.cppblog.com/chxzwj/aggbug/159099.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/chxzwj/" target="_blank">chxzwj</a> 2011-10-26 11:16 <a href="http://www.cppblog.com/chxzwj/articles/159099.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>图</title><link>http://www.cppblog.com/chxzwj/articles/159097.html</link><dc:creator>chxzwj</dc:creator><author>chxzwj</author><pubDate>Tue, 25 Oct 2011 16:31:00 GMT</pubDate><guid>http://www.cppblog.com/chxzwj/articles/159097.html</guid><wfw:comment>http://www.cppblog.com/chxzwj/comments/159097.html</wfw:comment><comments>http://www.cppblog.com/chxzwj/articles/159097.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/chxzwj/comments/commentRss/159097.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/chxzwj/services/trackbacks/159097.html</trackback:ping><description><![CDATA[<p>&nbsp;</p>
<div style="layout-grid:  15.6pt none">
<p style="margin-top: 0pt; text-indent: -21.25pt; margin-bottom: 0pt; margin-left: 21.25pt"><span style="font-family: 'Times New Roman'; font-size: 10.5pt">1.&nbsp;</span><span style="font-family: '宋体'; font-size: 10.5pt">图的基本概念</span><span style="font-family: 'Times New Roman'; font-size: 10.5pt"></span></p>
<p style="margin-top: 0pt; text-indent: -21.25pt; margin-bottom: 0pt; margin-left: 42.25pt"><span style="font-family: 'Times New Roman'; font-size: 10.5pt">1)&nbsp;</span><span style="font-family: '宋体'; font-size: 10.5pt">有向完全图</span></p>
<p style="margin-top: 0pt; text-indent: -21.25pt; margin-bottom: 0pt; margin-left: 42.25pt"><span style="font-family: 'Times New Roman'; font-size: 10.5pt">2)&nbsp;</span><span style="font-family: '宋体'; font-size: 10.5pt">无向完全图</span></p>
<p style="margin-top: 0pt; text-indent: -21.25pt; margin-bottom: 0pt; margin-left: 42.25pt"><span style="font-family: 'Times New Roman'; font-size: 10.5pt">3)&nbsp;</span><span style="font-family: '宋体'; font-size: 10.5pt">路径长度</span></p>
<p style="margin-top: 0pt; text-indent: -21.25pt; margin-bottom: 0pt; margin-left: 42.25pt"><span style="font-family: 'Times New Roman'; font-size: 10.5pt">4)&nbsp;</span><span style="font-family: '宋体'; font-size: 10.5pt">简单路径</span></p>
<p style="margin-top: 0pt; text-indent: -21.25pt; margin-bottom: 0pt; margin-left: 42.25pt"><span style="font-family: 'Times New Roman'; font-size: 10.5pt">5)&nbsp;</span><span style="font-family: '宋体'; font-size: 10.5pt">连通图，连通分量</span></p>
<p style="margin-top: 0pt; text-indent: -21.25pt; margin-bottom: 0pt; margin-left: 42.25pt"><span style="font-family: 'Times New Roman'; font-size: 10.5pt">6)&nbsp;</span><span style="font-family: '宋体'; font-size: 10.5pt">强连通图，强连通分量</span></p>
<p style="margin-top: 0pt; text-indent: -21.25pt; margin-bottom: 0pt; margin-left: 42.25pt"><span style="font-family: 'Times New Roman'; font-size: 10.5pt">7)&nbsp;</span><span style="font-family: '宋体'; font-size: 10.5pt">生成树，生成森林</span></p>
<p style="margin-top: 0pt; text-indent: -21.25pt; margin-bottom: 0pt; margin-left: 21.25pt"><span style="font-family: 'Times New Roman'; font-size: 10.5pt">2.&nbsp;</span><span style="font-family: '宋体'; font-size: 10.5pt">图的存储结构</span></p>
<p style="margin-top: 0pt; text-indent: -21.25pt; margin-bottom: 0pt; margin-left: 42.25pt"><span style="font-family: 'Times New Roman'; font-size: 10.5pt">1)&nbsp;</span><span style="font-family: '宋体'; font-size: 10.5pt">邻接矩阵：可方便计算入度和出度；基于此种结构的图，遍历结果唯一。</span></p>
<p style="margin-top: 0pt; text-indent: -21.25pt; margin-bottom: 0pt; margin-left: 42.25pt"><span style="font-family: 'Times New Roman'; font-size: 10.5pt">2)&nbsp;</span><span style="font-family: '宋体'; font-size: 10.5pt">邻接表：适用于点多边少的情况；基于此种结构的图，遍历不唯一（邻接表不唯一）</span></p>
<p style="margin-top: 0pt; text-indent: -21.25pt; margin-bottom: 0pt; margin-left: 21.25pt"><span style="font-family: 'Times New Roman'; font-size: 10.5pt">3.&nbsp;</span><span style="font-family: '宋体'; font-size: 10.5pt">图的遍历：通过遍历，可以求得图的所有连通分量</span></p>
<p style="margin-top: 0pt; text-indent: -21.25pt; margin-bottom: 0pt; margin-left: 42.25pt"><span style="font-family: 'Times New Roman'; font-size: 10.5pt">1)&nbsp;</span><span style="font-family: '宋体'; font-size: 10.5pt">深度优先遍历：类似于二叉树的先序遍历</span></p>
<p style="margin-top: 0pt; text-indent: -21.25pt; margin-bottom: 0pt; margin-left: 42.25pt"><span style="font-family: 'Times New Roman'; font-size: 10.5pt">2)&nbsp;</span><span style="font-family: '宋体'; font-size: 10.5pt">广度优先遍历：类似于二叉树的层次遍历</span></p>
<p style="margin-top: 0pt; text-indent: -21.25pt; margin-bottom: 0pt; margin-left: 21.25pt"><span style="font-family: 'Times New Roman'; font-size: 10.5pt">4.&nbsp;</span><span style="font-family: '宋体'; font-size: 10.5pt">最小生成树</span></p>
<p style="margin-top: 0pt; text-indent: -21.25pt; margin-bottom: 0pt; margin-left: 42.25pt"><span style="font-family: 'Times New Roman'; font-size: 10.5pt">1)&nbsp;</span><span style="font-family: '宋体'; font-size: 10.5pt">普利姆算法（从某点开始，逐次搜索，添加节点，）</span></p>
<p style="margin-top: 0pt; text-indent: -21.25pt; margin-bottom: 0pt; margin-left: 42.25pt"><span style="font-family: 'Times New Roman'; font-size: 10.5pt">2)&nbsp;</span><span style="font-family: '宋体'; font-size: 10.5pt">克鲁斯卡尔算法</span></p>
<p style="margin-top: 0pt; text-indent: -21.25pt; margin-bottom: 0pt; margin-left: 21.25pt"><span style="font-family: 'Times New Roman'; font-size: 10.5pt">5.&nbsp;</span><span style="font-family: '宋体'; font-size: 10.5pt">最短路径</span></p>
<p style="margin-top: 0pt; text-indent: -21.25pt; margin-bottom: 0pt; margin-left: 42.25pt"><span style="font-family: 'Times New Roman'; font-size: 10.5pt">1)&nbsp;</span><span style="font-family: '宋体'; font-size: 10.5pt">迪杰斯特拉算法</span></p>
<p style="margin-top: 0pt; text-indent: -21.25pt; margin-bottom: 0pt; margin-left: 42.25pt"><span style="font-family: 'Times New Roman'; font-size: 10.5pt">2)&nbsp;</span><span style="font-family: '宋体'; font-size: 10.5pt">佛罗里德算法</span></p>
<p style="margin-top: 0pt; text-indent: -21.25pt; margin-bottom: 0pt; margin-left: 21.25pt"><span style="font-family: 'Times New Roman'; font-size: 10.5pt">6.&nbsp;</span><span style="font-family: '宋体'; font-size: 10.5pt">拓扑排序：图的拓扑排序可以接触依赖关系以及判定图中是否有环。</span></p>
<p style="margin-top: 0pt; text-indent: -21.25pt; margin-bottom: 0pt; margin-left: 21.25pt"><span style="font-family: 'Times New Roman'; font-size: 10.5pt">7.&nbsp;</span><span style="font-family: '宋体'; font-size: 10.5pt">关键路径：通过</span><span style="font-family: '宋体'; font-size: 10.5pt">AOE，可以求得图中顶点的最早开始时间，最晚开始时间，活动的最早开始时间，以及活动的最晚开始时间。</span></p></div>
<p><!--EndFragment--></p><img src ="http://www.cppblog.com/chxzwj/aggbug/159097.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/chxzwj/" target="_blank">chxzwj</a> 2011-10-26 00:31 <a href="http://www.cppblog.com/chxzwj/articles/159097.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>排序</title><link>http://www.cppblog.com/chxzwj/articles/158969.html</link><dc:creator>chxzwj</dc:creator><author>chxzwj</author><pubDate>Mon, 24 Oct 2011 03:30:00 GMT</pubDate><guid>http://www.cppblog.com/chxzwj/articles/158969.html</guid><wfw:comment>http://www.cppblog.com/chxzwj/comments/158969.html</wfw:comment><comments>http://www.cppblog.com/chxzwj/articles/158969.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/chxzwj/comments/commentRss/158969.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/chxzwj/services/trackbacks/158969.html</trackback:ping><description><![CDATA[<div style="layout-grid:  15.6pt none">
<p style="text-align: justify; margin-top: 0pt; text-indent: -21.25pt; margin-bottom: 0pt; text-autospace: ; margin-left: 21.25pt"><span style="font-family: 'Times New Roman'; font-size: 10.5pt">1.&nbsp;</span><span style="font-family: '宋体'; font-size: 10.5pt">排序的基本概念</span><span style="font-family: 'Verdana'; font-size: 9.5pt"></span></p>
<p style="text-align: justify; margin-top: 0pt; text-indent: -21.25pt; margin-bottom: 0pt; text-autospace: ; margin-left: 42.25pt"><span style="font-family: '宋体'; font-size: 10.5pt">1</span><span style="font-family: 'Times New Roman'; font-size: 10.5pt">)&nbsp;</span><span style="font-family: '宋体'; font-size: 10.5pt">排序过程可以是物理重排,也可以是通过指针,使得逻辑有序.</span></p>
<p style="text-align: justify; margin-top: 0pt; text-indent: -21.25pt; margin-bottom: 0pt; text-autospace: ; margin-left: 42.25pt"><span style="font-family: '宋体'; font-size: 10.5pt">2</span><span style="font-family: 'Times New Roman'; font-size: 10.5pt">)&nbsp;</span><span style="font-family: '宋体'; font-size: 10.5pt">内部排序和外排序:所有的记录都在内存中,这样的排序为内部排序;如果排序的过程中要不断的进行内存与外存的交换,这样的排序为外部排序.</span></p>
<p style="text-align: justify; margin-top: 0pt; text-indent: -21.25pt; margin-bottom: 0pt; text-autospace: ; margin-left: 21.25pt"><span style="font-family: 'Times New Roman'; font-size: 10.5pt">2.&nbsp;</span><span style="font-family: '宋体'; font-size: 10.5pt">插入排序:</span></p>
<p style="text-align: justify; margin-top: 0pt; text-indent: -21.25pt; margin-bottom: 0pt; text-autospace: ; margin-left: 42.25pt"><span style="font-family: 'Times New Roman'; font-size: 10.5pt">1)&nbsp;</span><span style="font-family: '宋体'; font-size: 10.5pt">直接插入排序:</span><span style="font-family: '宋体'; font-size: 10.5pt">稳定的排序算法，时间复杂度：最好情况</span><span style="font-family: '宋体'; font-size: 10.5pt">O(n)；最差情况O（n^2）；平均情况为O（n^2）;</span></p>
<p style="text-align: justify; margin-top: 0pt; text-indent: -21.25pt; margin-bottom: 0pt; text-autospace: ; margin-left: 42.25pt"><span style="font-family: 'Times New Roman'; font-size: 10.5pt">2)&nbsp;</span><span style="font-family: '宋体'; font-size: 10.5pt">折半插入排序</span><span style="font-family: '宋体'; font-size: 10.5pt">：稳定的排序算法</span></p>
<p style="text-align: justify; margin-top: 0pt; text-indent: -21.25pt; margin-bottom: 0pt; text-autospace: ; margin-left: 42.25pt"><span style="font-family: 'Times New Roman'; font-size: 10.5pt">3)&nbsp;</span><span style="font-family: '宋体'; font-size: 10.5pt">希尔排序</span><span style="font-family: '宋体'; font-size: 10.5pt">：不稳定的排序算法，时间复杂度为：没有最好情况；最差情况</span><span style="font-family: '宋体'; font-size: 10.5pt">O（nlog2n）；平均情况为O(nlog2n)。</span></p>
<p style="text-align: justify; margin-top: 0pt; text-indent: -21.25pt; margin-bottom: 0pt; text-autospace: ; margin-left: 21.25pt"><span style="font-family: 'Times New Roman'; font-size: 10.5pt">3.&nbsp;</span><span style="font-family: '宋体'; font-size: 10.5pt">交换排序</span></p>
<p style="text-align: justify; margin-top: 0pt; text-indent: -21.25pt; margin-bottom: 0pt; text-autospace: ; margin-left: 42.25pt"><span style="font-family: 'Times New Roman'; font-size: 10.5pt">1)&nbsp;</span><span style="font-family: '宋体'; font-size: 10.5pt">气泡排序</span><span style="font-family: '宋体'; font-size: 10.5pt">：稳定的排序算法，时间复杂度为</span><span style="font-family: '宋体'; font-size: 10.5pt">:最好情况O（n）；最差情况O(n^2);平均情况为O（n^2）.</span></p>
<p style="text-align: justify; margin-top: 0pt; text-indent: -21.25pt; margin-bottom: 0pt; text-autospace: ; margin-left: 42.25pt"><span style="font-family: 'Times New Roman'; font-size: 10.5pt">2)&nbsp;</span><span style="font-family: '宋体'; font-size: 10.5pt">快速排序</span><span style="font-family: '宋体'; font-size: 10.5pt">:不稳定的排序算法，时间复杂度为：最好的情况O(nlog2n)；最差情况O(n^2)，平均情况为O(nlog2n)；</span></p>
<p style="text-align: justify; margin-top: 0pt; text-indent: -21.25pt; margin-bottom: 0pt; text-autospace: ; margin-left: 21.25pt"><span style="font-family: 'Times New Roman'; font-size: 10.5pt">4.&nbsp;</span><span style="font-family: '宋体'; font-size: 10.5pt">选择排序</span></p>
<p style="text-align: justify; margin-top: 0pt; text-indent: -21.25pt; margin-bottom: 0pt; text-autospace: ; margin-left: 42.25pt"><span style="font-family: 'Times New Roman'; font-size: 10.5pt">1)&nbsp;</span><span style="font-family: '宋体'; font-size: 10.5pt">简单选择排序</span><span style="font-family: '宋体'; font-size: 10.5pt">：不稳定的排序，时间复杂度为：最好情况</span><span style="font-family: '宋体'; font-size: 10.5pt">O(n^2);最差情况为O（n^2）;平均情况为O（n^2）;与关键字的初始排列无关。</span></p>
<p style="text-align: justify; margin-top: 0pt; text-indent: -21.25pt; margin-bottom: 0pt; text-autospace: ; margin-left: 42.25pt"><span style="font-family: 'Times New Roman'; font-size: 10.5pt">2)&nbsp;</span><span style="font-family: '宋体'; font-size: 10.5pt">堆排序</span><span style="font-family: '宋体'; font-size: 10.5pt">:不稳定的排序，时间复杂度为：最好情况O（nlog2n）；最差情况为O（nlog2n）；平均情况O（nlog2n）；</span></p>
<p style="text-align: justify; margin-top: 0pt; text-indent: -21.25pt; margin-bottom: 0pt; text-autospace: ; margin-left: 21.25pt"><span style="font-family: 'Times New Roman'; font-size: 10.5pt">5.&nbsp;</span><span style="font-family: '宋体'; font-size: 10.5pt">二路归并排序</span>&nbsp;</p>
<p style="text-align: justify; margin-top: 0pt; text-indent: 21pt; margin-bottom: 0pt; text-autospace: ; margin-left: 21.25pt"><span style="font-family: '宋体'; font-size: 10.5pt">稳定的排序，时间复杂度为：最好情况O（nlog2n）；最差情况为O（nlog2n）；平均情况O（nlog2n）；</span></p>
<p style="text-align: justify; margin-top: 0pt; text-indent: -21.25pt; margin-bottom: 0pt; text-autospace: ; margin-left: 21.25pt"><span style="font-family: '宋体'; font-size: 10.5pt">6.&nbsp;</span><span style="font-family: '宋体'; font-size: 10.5pt">基数排序</span></p>
<p style="text-align: justify; margin-top: 0pt; text-indent: 21pt; margin-bottom: 0pt; text-autospace: ; margin-left: 21pt"><span style="font-family: '宋体'; font-size: 10.5pt">稳定的排序，时间复杂度为：最好情况O（d（n+rd））；最差情况为O（d（n+rd））；平均情况O（d（n+rd））；</span></p>
<p style="text-align: justify; margin-top: 0pt; margin-bottom: 0pt; text-autospace: "></p>
<p style="text-align: justify; margin-top: 0pt; margin-bottom: 0pt; text-autospace: "></p>
<p style="text-align: justify; margin-top: 0pt; margin-bottom: 0pt; text-autospace: "></p></div><!--EndFragment--><img src ="http://www.cppblog.com/chxzwj/aggbug/158969.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/chxzwj/" target="_blank">chxzwj</a> 2011-10-24 11:30 <a href="http://www.cppblog.com/chxzwj/articles/158969.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>树</title><link>http://www.cppblog.com/chxzwj/articles/158891.html</link><dc:creator>chxzwj</dc:creator><author>chxzwj</author><pubDate>Sat, 22 Oct 2011 13:30:00 GMT</pubDate><guid>http://www.cppblog.com/chxzwj/articles/158891.html</guid><wfw:comment>http://www.cppblog.com/chxzwj/comments/158891.html</wfw:comment><comments>http://www.cppblog.com/chxzwj/articles/158891.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/chxzwj/comments/commentRss/158891.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/chxzwj/services/trackbacks/158891.html</trackback:ping><description><![CDATA[<div><p style="margin-left: 21.25pt; text-indent: -21.25pt; margin-bottom: 0pt; margin-top: 0pt; "><font class="Apple-style-span" face="'Times New Roman'"></font></p><div><p style="margin-left:21.2500pt; text-indent:-21.2500pt; margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; "><font class="Apple-style-span" face="'Times New Roman'"><span style=" font-size:10.5000pt; font-family:'Times New Roman'; ">1.&nbsp;</span><span style=" font-size:10.5000pt; font-family:'宋体'; ">与树有关的概念</span></font></p><p style="margin-left:42.2500pt; text-indent:-21.2500pt; margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; "><font class="Apple-style-span" face="'Times New Roman'"><span style=" font-size:10.5000pt; font-family:'Times New Roman'; ">1)&nbsp;</span><span style=" font-size:10.5000pt; font-family:'宋体'; ">结点的度：结点拥有的子树数。</span></font></p><p style="margin-left:42.2500pt; text-indent:-21.2500pt; margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; "><font class="Apple-style-span" face="'Times New Roman'"><span style=" font-size:10.5000pt; font-family:'Times New Roman'; ">2)&nbsp;</span><span style=" font-size:10.5000pt; font-family:'宋体'; ">树的度：树中所有结点的度的最大值。</span></font></p><p style="margin-left:42.2500pt; text-indent:-21.2500pt; margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; "><font class="Apple-style-span" face="'Times New Roman'"><span style=" font-size:10.5000pt; font-family:'Times New Roman'; ">3)&nbsp;</span><span style=" font-size:10.5000pt; font-family:'宋体'; ">结点的层数：</span></font></p><p style="margin-left:42.2500pt; text-indent:-21.2500pt; margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; "><font class="Apple-style-span" face="'Times New Roman'"><span style=" font-size:10.5000pt; font-family:'Times New Roman'; ">4)&nbsp;</span><span style=" font-size:10.5000pt; font-family:'宋体'; ">树的深度：树中结点的最大层数或者称为树的高度或者深度。</span></font></p><p style="margin-left:42.2500pt; text-indent:-21.2500pt; margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; "><font class="Apple-style-span" face="'Times New Roman'"><span style=" font-size:10.5000pt; font-family:'Times New Roman'; ">5)&nbsp;</span><span style=" font-size:10.5000pt; font-family:'宋体'; ">叶子结点：度为0的点或者终端节点。</span></font></p><p style="margin-left:42.2500pt; text-indent:-21.2500pt; margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; "><font class="Apple-style-span" face="'Times New Roman'"><span style=" font-size:10.5000pt; font-family:'Times New Roman'; ">6)&nbsp;</span><span style=" font-size:10.5000pt; font-family:'宋体'; ">分支结点：度大于0的结点。</span></font></p><p style="margin-left:42.2500pt; text-indent:-21.2500pt; margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; "><font class="Apple-style-span" face="'Times New Roman'"><span style=" font-size:10.5000pt; font-family:'Times New Roman'; ">7)&nbsp;</span><span style=" font-size:10.5000pt; font-family:'宋体'; ">森林：m棵互不相交的树的集合为森林</span></font></p><p style="margin-left:42.2500pt; text-indent:-21.2500pt; margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; "><font class="Apple-style-span" face="'Times New Roman'"><span style=" font-size:10.5000pt; font-family:'Times New Roman'; ">8)&nbsp;</span><span style=" font-size:10.5000pt; font-family:'宋体'; ">树不允许为空。但是二叉树允许为空，二叉树不是树，并且二叉树是有序树，左孩子和右孩子是不一样的。</span></font></p><p style="margin-left:21.2500pt; text-indent:-21.2500pt; margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; "><font class="Apple-style-span" face="'Times New Roman'"><span style=" font-size:10.5000pt; font-family:'Times New Roman'; ">2.&nbsp;</span><span style=" font-size:10.5000pt; font-family:'宋体'; ">二叉树概念：有限个元素的集合，该集合或者为空、或者有一个称为根的元素以及两两不相交的、分别称为左子树和右子树的组成。</span></font></p><p style="margin-left:42.2500pt; text-indent:-21.2500pt; margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; "><font class="Apple-style-span" face="'Times New Roman'"><span style=" font-size:10.5000pt; font-family:'Times New Roman'; ">1)&nbsp;</span><span style=" font-size:10.5000pt; font-family:'宋体'; ">二叉树的性质如下：</span></font></p><p style="margin-left:21.0000pt; text-indent:20.0000pt; margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; "><font class="Apple-style-span" face="'Times New Roman'"><span style=" font-size:10.5000pt; font-family:'宋体'; ">&#9312;　二叉树的第i层，共有2^（i-1）个结点。</span></font></p><p style="margin-left:21.0000pt; text-indent:20.0000pt; margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; "><font class="Apple-style-span" face="'Times New Roman'"><span style=" font-size:10.5000pt; font-family:'宋体'; ">&#9313;　深度为k二叉树最多有2^k-1个结点。</span></font></p><p style="margin-left:21.0000pt; text-indent:20.0000pt; margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; "><font class="Apple-style-span" face="'Times New Roman'"><span style=" font-size:10.5000pt; font-family:'宋体'; ">&#9314;　二叉树中，终端节点的数目为n0；度为1的结点数目为n1，度为2的结点为n2；则n0&nbsp;=&nbsp;n2+1；</span></font></p><p style="margin-left:41.0000pt; margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; "><font class="Apple-style-span" face="'Times New Roman'"><span style=" font-size:10.5000pt; font-family:'宋体'; ">&nbsp;&nbsp;&nbsp;&nbsp;据此，可以引出一下结论,对于n个结点的完全二叉树：</span></font></p><p style="margin-left:41.0000pt; text-indent:21.0000pt; margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; "><font class="Apple-style-span" face="'Times New Roman'"><span style=" font-size:10.5000pt; font-family:'宋体'; ">a&gt;,若n为奇数，则树中只有度为2和度为0的结点。其中度为2的结点数为&nbsp;&nbsp;(n-1)/2；度为0的结点数为(n-1)/2+1；</span></font></p><p style="margin-left:41.0000pt; text-indent:21.0000pt; margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; "><font class="Apple-style-span" face="'Times New Roman'"><span style=" font-size:10.5000pt; font-family:'宋体'; ">b&gt;,若n为偶数，则树中除了度为2和度为0的结点结点外，还有度为1的结点1个。</span></font></p><p style="margin-left:21.0000pt; text-indent:20.0000pt; margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; "><font class="Apple-style-span" face="'Times New Roman'"><span style=" font-size:10.5000pt; font-family:'宋体'; ">&#9315;　如果有一棵n个结点的完全二叉树，自上自下，同一层自左到右连续给结点编号，则有如下关系：</span></font></p><p style="margin-left:41.0000pt; text-indent:21.0000pt; margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; "><font class="Apple-style-span" face="'Times New Roman'"><span style=" font-size:10.5000pt; font-family:'宋体'; ">a&gt;,若i=1，则结点为i为根结点，若i&gt;1，则结点i的父节点为『i/2』；</span></font></p><p style="margin-left:41.0000pt; text-indent:21.0000pt; margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; "><font class="Apple-style-span" face="'Times New Roman'"><span style=" font-size:10.5000pt; font-family:'宋体'; ">b&gt;,若2i&lt;n,则结点i的左孩子结点为2i；</span></font></p><p style="margin-left:41.0000pt; text-indent:21.0000pt; margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; "><font class="Apple-style-span" face="'Times New Roman'"><span style=" font-size:10.5000pt; font-family:'宋体'; ">c&gt;,若2i+1&lt;n;则结点i的右孩子结点为2i+1；</span></font></p><p style="margin-left:41.0000pt; text-indent:21.0000pt; margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; "><font class="Apple-style-span" face="'Times New Roman'"><span style=" font-size:10.5000pt; font-family:'宋体'; ">d&gt;,若结点i为奇数，则左子树结点为i-1；</span></font></p><p style="margin-left:41.0000pt; text-indent:21.0000pt; margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; "><font class="Apple-style-span" face="'Times New Roman'"><span style=" font-size:10.5000pt; font-family:'宋体'; ">e&gt;,若结点i为偶数，则右子树结点为i+1；</span></font></p><p style="margin-left:41.0000pt; text-indent:21.0000pt; margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; "><font class="Apple-style-span" face="'Times New Roman'"><span style=" font-size:10.5000pt; font-family:'宋体'; ">f&gt;,结点i所在的层次为log2i+1；</span></font></p><p style="margin-left:41.0000pt; text-indent:21.0000pt; margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; "><font class="Apple-style-span" face="'Times New Roman'"><span style=" font-size:10.5000pt; font-family:'宋体'; ">由此可以引入如下结论：对于完全二叉树编号为i的结点有：</span></font></p><p style="margin-left:41.0000pt; text-indent:21.0000pt; margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; "><font class="Apple-style-span" face="'Times New Roman'"><span style=" font-size:10.5000pt; font-family:'宋体'; ">1&gt;,若i&lt;=n/2，则编号为i的结点为分支结点，否则为叶结点</span></font></p><p style="margin-left:41.0000pt; text-indent:21.0000pt; margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; "><font class="Apple-style-span" face="'Times New Roman'"><span style=" font-size:10.5000pt; font-family:'宋体'; ">2&gt;,若n为奇数，则每个分支结点都有左子树和右子树；若n为偶数，则编号最大的分支结点只有左子树。</span></font></p><p style="margin-left:21.0000pt; text-indent:20.0000pt; margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; "><font class="Apple-style-span" face="'Times New Roman'"><span style=" font-size:10.5000pt; font-family:'宋体'; ">&#9316;　&nbsp;具有n个结点的完全二叉树的深度为log2（n+1）（向上取整）</span></font></p><p style="margin-left:42.2500pt; text-indent:-21.2500pt; margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; "><font class="Apple-style-span" face="'Times New Roman'"><span style=" font-size:10.5000pt; font-family:'Times New Roman'; ">2)&nbsp;</span><span style=" font-size:10.5000pt; font-family:'宋体'; ">二叉树的存储结构</span></font></p><p style="margin-left:21.0000pt; text-indent:20.0000pt; margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; "><font class="Apple-style-span" face="'Times New Roman'"><span style=" font-size:10.5000pt; font-family:'宋体'; ">&#9312;　二叉树的顺序存储结构一般适用于完全二叉树。</span></font></p><p style="margin-left:21.0000pt; text-indent:20.0000pt; margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; "><font class="Apple-style-span" face="'Times New Roman'"><span style=" font-size:10.5000pt; font-family:'宋体'; ">&#9313;　二叉树的链式存储结构，有二叉链表和三叉链表。</span></font></p><p style="text-indent:21.0000pt; margin-bottom:3.7500pt; margin-top:3.7500pt; text-autospace:ideograph-other; "><font class="Apple-style-span" face="'Times New Roman'"><span style=" font-size:10.5000pt; font-family:'Times New Roman'; ">3)&nbsp;</span><span style=" font-size:10.5000pt; font-family:'宋体'; ">二叉树的遍历</span>&nbsp;</font></p><p style="margin-left:21.0000pt; text-indent:20.0000pt; margin-bottom:3.7500pt; margin-top:3.7500pt; text-autospace:ideograph-other; "><font class="Apple-style-span" face="'Times New Roman'"><span style=" font-size:10.5000pt; font-family:'宋体'; ">&#9312;　</span><span style=" font-size:10.5000pt; font-family:'宋体'; ">中序递归遍历</span></font></p><p style="margin-left:21.0000pt; text-indent:20.0000pt; margin-bottom:3.7500pt; margin-top:3.7500pt; text-autospace:ideograph-other; "><font class="Apple-style-span" face="'Times New Roman'"><span style=" font-size:10.5000pt; font-family:'宋体'; ">&#9313;　</span><span style=" font-size:10.5000pt; font-family:'宋体'; ">先序递归遍历</span></font></p><p style="margin-left:21.0000pt; text-indent:20.0000pt; margin-bottom:3.7500pt; margin-top:3.7500pt; text-autospace:ideograph-other; "><font class="Apple-style-span" face="'Times New Roman'"><span style=" font-size:10.5000pt; font-family:'宋体'; ">&#9314;　</span><span style=" font-size:10.5000pt; font-family:'宋体'; ">后序递归遍历</span></font></p><p style="margin-left:21.0000pt; text-indent:20.0000pt; margin-bottom:3.7500pt; margin-top:3.7500pt; text-autospace:ideograph-other; "><font class="Apple-style-span" face="'Times New Roman'"><span style=" font-size:10.5000pt; font-family:'宋体'; ">&#9315;　</span><span style=" font-size:10.5000pt; font-family:'宋体'; ">中序非递归</span></font></p><p style="margin-left:21.0000pt; text-indent:20.0000pt; margin-bottom:3.7500pt; margin-top:3.7500pt; text-autospace:ideograph-other; "><font class="Apple-style-span" face="'Times New Roman'"><span style=" font-size:10.5000pt; font-family:'宋体'; ">&#9316;　</span><span style=" font-size:10.5000pt; font-family:'宋体'; ">后序非递归</span></font></p><p style="margin-left:21.0000pt; text-indent:20.0000pt; margin-bottom:3.7500pt; margin-top:3.7500pt; text-autospace:ideograph-other; "><font class="Apple-style-span" face="'Times New Roman'"><span style=" font-size:10.5000pt; font-family:'宋体'; ">&#9317;　</span><span style=" font-size:10.5000pt; font-family:'宋体'; ">先序非递归</span></font></p><p style="margin-left:21.0000pt; text-indent:20.0000pt; margin-bottom:3.7500pt; margin-top:3.7500pt; text-autospace:ideograph-other; "><font class="Apple-style-span" face="'Times New Roman'"><span style=" font-size:10.5000pt; font-family:'宋体'; ">&#9318;　</span><span style=" font-size:10.5000pt; font-family:'宋体'; ">层次遍历</span></font></p><p style="margin-left:21.2500pt; text-indent:-21.2500pt; margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; "><font class="Apple-style-span" face="'Times New Roman'"><span style=" font-size:10.5000pt; font-family:'宋体'; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=" font-size:10.5000pt; font-family:'Times New Roman'; ">4)&nbsp;</span><span style=" font-size:10.5000pt; font-family:'宋体'; ">线索二叉树</span></font></p><p style="margin-left:21.2500pt; text-indent:-21.2500pt; margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; "><font class="Apple-style-span" face="'Times New Roman'"><span style=" font-size:10.5000pt; font-family:'宋体'; ">3</span><span style=" font-size:10.5000pt; font-family:'Times New Roman'; ">.</span>&nbsp;<span style=" font-size:10.5000pt; font-family:'宋体'; ">树与森林</span></font></p><p style="margin-left:42.2500pt; text-indent:-21.2500pt; margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; "><font class="Apple-style-span" face="'Times New Roman'"><span style=" font-size:10.5000pt; font-family:'Times New Roman'; ">1)&nbsp;</span><span style=" font-size:10.5000pt; font-family:'宋体'; ">树的存储结构</span></font></p><p style="margin-left:42.2500pt; text-indent:-21.2500pt; margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; "><font class="Apple-style-span" face="'Times New Roman'"><span style=" font-size:10.5000pt; font-family:'Times New Roman'; ">2)&nbsp;</span><span style=" font-size:10.5000pt; font-family:'宋体'; ">森林，树与二叉树的转换</span></font></p><p style="margin-left:42.2500pt; text-indent:-21.2500pt; margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; "><font class="Apple-style-span" face="'Times New Roman'"><span style=" font-size:10.5000pt; font-family:'Times New Roman'; ">3)&nbsp;</span><span style=" font-size:10.5000pt; font-family:'宋体'; ">森林与树的遍历</span></font></p><p style="margin-left:21.2500pt; text-indent:-21.2500pt; margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; "><font class="Apple-style-span" face="'Times New Roman'"><span style=" font-size:10.5000pt; font-family:'Times New Roman'; ">4.&nbsp;</span><span style=" font-size:10.5000pt; font-family:'宋体'; ">树的应用</span></font></p><p style="margin-left:42.2500pt; text-indent:-21.2500pt; margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; "><font class="Apple-style-span" face="'Times New Roman'"><span style=" font-size:10.5000pt; font-family:'Times New Roman'; ">1)&nbsp;</span><span style=" font-size:10.5000pt; font-family:'宋体'; ">二叉排序树</span></font></p><p style="margin-left:42.2500pt; text-indent:-21.2500pt; margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; "><font class="Apple-style-span" face="'Times New Roman'"><span style=" font-size:10.5000pt; font-family:'Times New Roman'; ">2)&nbsp;</span><span style=" font-size:10.5000pt; font-family:'宋体'; ">平衡二叉树</span></font></p><p style="margin-left:42.2500pt; text-indent:-21.2500pt; margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; "><font class="Apple-style-span" face="'Times New Roman'"><span style=" font-size:10.5000pt; font-family:'Times New Roman'; ">3)&nbsp;</span><span style=" font-size:10.5000pt; font-family:'宋体'; ">哈夫曼树</span></font></p><p style="margin-left:42.2500pt; text-indent:-21.2500pt; margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; "><font class="Apple-style-span" face="'Times New Roman'"><span style=" font-size:10.5000pt; font-family:'Times New Roman'; ">4)&nbsp;</span><span style=" font-size:10.5000pt; font-family:'宋体'; ">堆</span></font></p><p style="margin-bottom:0pt; margin-top:0pt; "></p></div><p>&nbsp;</p><p style="margin-bottom:0pt; margin-top:0pt; "></p></div> <img src ="http://www.cppblog.com/chxzwj/aggbug/158891.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/chxzwj/" target="_blank">chxzwj</a> 2011-10-22 21:30 <a href="http://www.cppblog.com/chxzwj/articles/158891.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>线性表</title><link>http://www.cppblog.com/chxzwj/articles/158880.html</link><dc:creator>chxzwj</dc:creator><author>chxzwj</author><pubDate>Sat, 22 Oct 2011 07:44:00 GMT</pubDate><guid>http://www.cppblog.com/chxzwj/articles/158880.html</guid><wfw:comment>http://www.cppblog.com/chxzwj/comments/158880.html</wfw:comment><comments>http://www.cppblog.com/chxzwj/articles/158880.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/chxzwj/comments/commentRss/158880.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/chxzwj/services/trackbacks/158880.html</trackback:ping><description><![CDATA[<div><p style="margin-left: 21.25pt; text-indent: -21.25pt; margin-bottom: 0pt; margin-top: 0pt; "><span style=" font-size:10.5000pt; font-family:'Times New Roman'; "></span></p><span class="Apple-style-span" style="font-size: 13px; background-color: #eeeeee; "><span style="color: #000000; "><div><div><p style="margin-left:21.2500pt; text-indent:-21.2500pt; margin-bottom:0pt; margin-top:0pt; "><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Times New Roman'; ">1.&nbsp;</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体'; ">线性表的定义和操作</span></p><p style="text-indent:20.0000pt; margin-bottom:0pt; margin-top:0pt; "><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体'; ">&#9312;　</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体'; ">存在唯一的一个&#8220;称为第一个的元素&#8220;；</span></p><p style="text-indent:20.0000pt; margin-bottom:0pt; margin-top:0pt; "><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体'; ">&#9313;　</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体'; ">存在唯一的称为&#8221;最后一个&#8220;的元素，</span></p><p style="text-indent:20.0000pt; margin-bottom:0pt; margin-top:0pt; "><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体'; ">&#9314;　</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体'; ">除第一个元素外，其他的每个元素只有一个直接前驱；</span></p><p style="text-indent:20.0000pt; margin-bottom:0pt; margin-top:0pt; "><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体'; ">&#9315;　</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体'; ">除最后一个元素外，集合中的每个元素均只有一个直接后继；</span></p><p style="text-indent:20.0000pt; margin-bottom:0pt; margin-top:0pt; "><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体'; ">&#9316;　</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体'; ">最后两点，体现了线性表中元素之间的逻辑关系。</span></p><p style="margin-left:21.2500pt; text-indent:-21.2500pt; margin-bottom:0pt; margin-top:0pt; "><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Times New Roman'; ">2.&nbsp;</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体'; ">线性表的存储</span></p><p style="text-indent:20.0000pt; margin-bottom:0pt; margin-top:0pt; "><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体'; ">&#9312;　</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体'; ">顺序存储</span></p><p style="text-indent:20.0000pt; margin-bottom:0pt; margin-top:0pt; "><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体'; ">&#9313;　</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体'; ">链式存储</span></p><p style="margin-left:21.2500pt; text-indent:-21.2500pt; margin-bottom:0pt; margin-top:0pt; "><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Times New Roman'; ">3.&nbsp;</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体'; ">线性表的应用</span></p><p style="margin-bottom:0pt; margin-top:0pt; "></p></div></div></span></span></div><img src ="http://www.cppblog.com/chxzwj/aggbug/158880.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/chxzwj/" target="_blank">chxzwj</a> 2011-10-22 15:44 <a href="http://www.cppblog.com/chxzwj/articles/158880.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>