﻿<?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++博客-ACTime-随笔分类-组合数学</title><link>http://www.cppblog.com/liuhao/category/13038.html</link><description>let's start</description><language>zh-cn</language><lastBuildDate>Sat, 06 Feb 2010 03:06:36 GMT</lastBuildDate><pubDate>Sat, 06 Feb 2010 03:06:36 GMT</pubDate><ttl>60</ttl><item><title>卡特兰数（Catalan数）</title><link>http://www.cppblog.com/liuhao/archive/2010/02/06/107367.html</link><dc:creator>ACTime</dc:creator><author>ACTime</author><pubDate>Sat, 06 Feb 2010 02:43:00 GMT</pubDate><guid>http://www.cppblog.com/liuhao/archive/2010/02/06/107367.html</guid><wfw:comment>http://www.cppblog.com/liuhao/comments/107367.html</wfw:comment><comments>http://www.cppblog.com/liuhao/archive/2010/02/06/107367.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/liuhao/comments/commentRss/107367.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/liuhao/services/trackbacks/107367.html</trackback:ping><description><![CDATA[


<span style="font-family: Arial; font-size: 14px; line-height: 24px; "><h2 class="first" style="margin-top: 0px; margin-right: 0px; margin-bottom: 20px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 6px; padding-left: 0px; font-size: 18px; font-weight: bold; line-height: 24px; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(222, 223, 225); clear: none; ">&nbsp;&nbsp; &nbsp; &nbsp;原理</h2>　　令h(1)＝1,h(0)=1，catalan数满足递归式：<br>　　<strong>h(n)= h(0)*h(n-1)+h(1)*h(n-2) + ... + h(n-1)h(0) (其中n&gt;=2)<br></strong>　　另类递归式：<br>　　<strong>h(n)=((4*n-2)/(n+1))*h(n-1);<br></strong>　　该递推关系的解为：<br>　　<strong>h(n)=C(2n,n)/(n+1) (n=1,2,3,...)</strong></span><div><span style="font-family: Arial; font-size: 14px; line-height: 24px; "><strong><br></strong>　　卡特兰数的应用<br>　　（实质上都是递归等式的应用）<br>　　<h3 style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 28px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 16px; font-family: Arial; line-height: 22px; "><a name="1_1" style="color: rgb(51, 102, 204); text-decoration: underline; "></a>括号化问题</h3><br>　　矩阵链乘： P=a1&#215;a2&#215;a3&#215;&#8230;&#8230;&#215;an，依据乘法结合律，不改变其顺序，只用括号表示成对的乘积，试问有几种括号化的方案？(h(n)种)<br><div class="spctrl" style="font-family: Arial; font-size: 14px; text-align: left; height: 10px; line-height: 10px; "></div>　　<h3 style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 28px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 16px; font-family: Arial; line-height: 22px; "><a name="1_2" style="color: rgb(51, 102, 204); text-decoration: underline; "></a>出栈次序问题</h3><br>　　一个栈(无穷大)的进栈序列为1，2，3，&#8230;，n，有多少个不同的出栈序列?<br>　　分析：对于每一个数来说，必须进栈一次、出栈一次。我们把进栈设为状态&#8216;1&#8217;，出栈设为状态&#8216;0&#8217;。n个数的所有状态对应n个1和n个0组成的2n位二进制数。由于等待入栈的操作数按照1‥n的顺序排列、入栈的操作数b大于等于出栈的操作数a(a&#8804;b)，因此输出序列的总数目=由左而右扫描由n个1和n个0组成的2n位二进制数，1的累计数不小于0的累计数的方案种数。<br>　　在2n位二进制数中填入n个1的方案数为c(2n,n),不填1的其余n位自动填0。从中减去不符合要求（由左而右扫描，0的累计数大于1的累计数）的方案数即为所求。<br>　　不符合要求的数的特征是由左而右扫描时，必然在某一奇数位2m+1位上首先出现m+1个0的累计数和m个1的累计数，此后的2(n-m)-1位上有n-m个 1和n-m-1个0。如若把后面这2(n-m)-1位上的0和1互换，使之成为n-m个0和n-m-1个1，结果得1个由n+1个0和n-1个1组成的2n位数，即一个不合要求的数对应于一个由n+1个0和n-1个1组成的排列。<br>　　反过来，任何一个由n+1个0和n-1个1组成的2n位二进制数，由于0的个数多2个，2n为偶数，故必在某一个奇数位上出现0的累计数超过1的累计数。同样在后面部分0和1互换，使之成为由n个0和n个1组成的2n位数，即n+1个0和n-1个1组成的2n位数必对应一个不符合要求的数。<br>　　因而不合要求的2n位数与n＋1个0，n－1个1组成的排列一一对应。<br>　　显然，不符合要求的方案数为c(2n,n+1)。由此得出 输出序列的总数目=c(2n,n)-c(2n,n+1)=1/(n+1)*c(2n,n)。<br>　　（这个公式的下标是从h(0)=1开始的）<br>　　类似：有2n个人排成一行进入剧场。入场费5元。其中只有n个人有一张5元钞票，另外n人只有10元钞票，剧院无其它钞票，问有多少中方法使得只要有10元的人买票，售票处就有5元的钞票找零？(将持5元者到达视作将5元入栈，持10元者到达视作使栈中某5元出栈)<br>　　<h3 style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 28px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 16px; font-family: Arial; line-height: 22px; "><a name="1_3" style="color: rgb(51, 102, 204); text-decoration: underline; "></a>凸多边形的三角剖分问题</h3><br>　　<br>　　求将一个<a target="_blank" href="http://baike.baidu.com/view/363944.htm" style="color: rgb(51, 102, 204); text-decoration: underline; ">凸多边形</a>区域分成三角形区域的方法数。<br>　　类似：一位大城市的律师在她住所以北n个街区和以东n个街区处工作。每天她走2n个街区去上班。如果她从不穿越（但可以碰到）从家到办公室的对角线，那么有多少条可能的道路？<br>　　类似：在圆上选择2n个点,将这些点成对连接起来使得所得到的n条线段不相交的方法数?&nbsp;<br>　　<h3 style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 28px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 16px; font-family: Arial; line-height: 22px; "><a name="1_4" style="color: rgb(51, 102, 204); text-decoration: underline; "></a>用给定节点组成二叉树的问题</h3><br>　　<br>　　给定N个节点，能构成多少种不同的<a target="_blank" href="http://baike.baidu.com/view/88806.htm" style="color: rgb(51, 102, 204); text-decoration: underline; ">二叉树</a>？<br>　　（能构成h（N）个）</span>
</div><img src ="http://www.cppblog.com/liuhao/aggbug/107367.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/liuhao/" target="_blank">ACTime</a> 2010-02-06 10:43 <a href="http://www.cppblog.com/liuhao/archive/2010/02/06/107367.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>