<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>阅微堂 &#187; 理论计算机笔记</title>
	<atom:link href="http://zhiqiang.org/blog/tag/%e7%90%86%e8%ae%ba%e8%ae%a1%e7%ae%97%e6%9c%ba%e7%ac%94%e8%ae%b0/feed" rel="self" type="application/rss+xml" />
	<link>http://zhiqiang.org/blog</link>
	<description>理工科背景的证券从业人员</description>
	<lastBuildDate>Sun, 05 Feb 2012 03:59:13 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>摸箱子问题以及应用</title>
		<link>http://zhiqiang.org/blog/science/computer-science/boxes-problem-on-static-data-structure-problems.html</link>
		<comments>http://zhiqiang.org/blog/science/computer-science/boxes-problem-on-static-data-structure-problems.html#comments</comments>
		<pubDate>Tue, 16 Dec 2008 08:24:54 +0000</pubDate>
		<dc:creator>zhiqiang</dc:creator>
				<category><![CDATA[计算机科学]]></category>
		<category><![CDATA[概率]]></category>
		<category><![CDATA[游戏]]></category>
		<category><![CDATA[理论计算机笔记]]></category>

		<guid isPermaLink="false">http://zhiqiang.org/blog/posts/boxes-problem-on-static-data-structure-problems.html</guid>
		<description><![CDATA[博客 » 计算机科学 » 概率 » 系列：理论计算机笔记 查看该系列所有文章 以前提到过，理论计算机这门课会邀请一些正在这边访问的教授来讲课，由于是本科生，所以这些教授一般都是讲些有趣的东西，比如之前的overhang 堆积木 - 能伸出桌面多远？。今天这次课，来自Aarhus的Peter Bro Miltersen讲了一个很有趣的游戏问题。 现在有100个箱子，有一个学生，一张写着他的名字的名片...]]></description>
			<content:encoded><![CDATA[<p id="breadcrumb" class="breadcrumb"><a href="http://zhiqiang.org/blog/">博客</a> » <a href="http://zhiqiang.org/blog/category/science/computer-science">计算机科学</a> » <a href='http://zhiqiang.org/blog/tag/%e6%a6%82%e7%8e%87'>概率</a>  » </p><div class="series"><span>系列：<b>理论计算机笔记</b></span><br/>
<a href="http://zhiqiang.org/blog/tag/%e7%90%86%e8%ae%ba%e8%ae%a1%e7%ae%97%e6%9c%ba%e7%ac%94%e8%ae%b0">查看该系列所有文章</a>
<div id='series'></div>
</div>  <p>以前提到过，理论计算机这门课会邀请一些正在这边访问的教授来讲课，由于是本科生，所以这些教授一般都是讲些有趣的东西，比如之前的<a href="http://zhiqiang.org/blog/science/overhang-stacking-wood-how-far-can-extend-desktop.html">overhang 堆积木 - 能伸出桌面多远？</a>。今天这次课，来自Aarhus的<a href="http://cs.au.dk/~bromille/">Peter Bro Miltersen</a>讲了一个很有趣的游戏问题。</p>
<p>现在有100个箱子，有一个学生，一张写着他的名字的名片被放在某个随机选择的箱子里面。现在这个学生可以检查不超过一半也就是50个箱子，希望能够把它的名字找出来。</p>
<p>很显然，这个学生没有什么好的方法，随机选择50个箱子打开，有一半的概率可以发现含有它的名字纸条的箱子。</p>
<p>OK，现在还是100个箱子，但是有100个学生，写着这些学生的名字的100张纸条随机放入100个箱子里(每个箱子恰好一张纸条)。现在每个学生可以检查不超过一半也就是50个箱子，每个学生希望能找到含有自己名字的箱子。如果在游戏中，所有学生都是独立的（他们不能互相讨论以及看到其他人的开箱结果），问所有学生都实现目标的概率有多大？</p>
<p>如果把每个学生的结果认为是独立的，那么成功的概率只有<span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_5deb1f2a4cb23a636322677c5b5711f8.gif' style='vertical-align: middle; border: none; ' class='tex' alt="2^{-100}" /></span><script type='math/tex'>2^{-100}</script>，但其实我们可以做的比这要好得多。事实上，让每个学生都找到含有自己名字的箱子的概率可以高达0.3。</p>
<p>假设学生的名字就是它的编号，从1到100。第<span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_865c0c0b4ab0e063e5caa3387c1a8741.gif' style='vertical-align: middle; border: none; padding-bottom:1px;' class='tex' alt="i" /></span><script type='math/tex'>i</script>个箱子里的编号是<span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_337778f4c628d9c80045adbc3a9a81b0.gif' style='vertical-align: middle; border: none; ' class='tex' alt="\pi(i)" /></span><script type='math/tex'>\pi(i)</script>。第<span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_865c0c0b4ab0e063e5caa3387c1a8741.gif' style='vertical-align: middle; border: none; padding-bottom:1px;' class='tex' alt="i" /></span><script type='math/tex'>i</script>个学生这样做：先打开第<span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_865c0c0b4ab0e063e5caa3387c1a8741.gif' style='vertical-align: middle; border: none; padding-bottom:1px;' class='tex' alt="i" /></span><script type='math/tex'>i</script>个箱子，再打开第<span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_337778f4c628d9c80045adbc3a9a81b0.gif' style='vertical-align: middle; border: none; ' class='tex' alt="\pi(i)" /></span><script type='math/tex'>\pi(i)</script>个箱子，再打开第<span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_30e74848e17f1241028df30d37626fb5.gif' style='vertical-align: middle; border: none; ' class='tex' alt="\pi(\pi(i))" /></span><script type='math/tex'>\pi(\pi(i))</script>个箱子，以此继续下去，直到发现写着自己名字（也就是<span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_865c0c0b4ab0e063e5caa3387c1a8741.gif' style='vertical-align: middle; border: none; padding-bottom:1px;' class='tex' alt="i" /></span><script type='math/tex'>i</script>）的纸条或者打开箱子数到达50个为止。</p>
<p>那么当且仅当在<span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_865c0c0b4ab0e063e5caa3387c1a8741.gif' style='vertical-align: middle; border: none; padding-bottom:1px;' class='tex' alt="i" /></span><script type='math/tex'>i</script>到<span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_337778f4c628d9c80045adbc3a9a81b0.gif' style='vertical-align: middle; border: none; ' class='tex' alt="\pi(i)" /></span><script type='math/tex'>\pi(i)</script>这个置换中含有长度超过50的圈时，有学生找不到含有自己名字的箱子。这个概率是<span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_8dde40b065bb39ce68f1acf77b65f3d8.gif' style='vertical-align: middle; border: none; ' class='tex' alt="\sum_{j=51}^{100}1/j \sim \ln 2" /></span><script type='math/tex'>\sum_{j=51}^{100}1/j \sim \ln 2</script>（注意一个随机置换里含有一个长度为<span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_363b122c528f54df4a0446b6bab05515.gif' style='vertical-align: middle; border: none; ' class='tex' alt="j" /></span><script type='math/tex'>j</script>的圈的概率为<span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_f1efbba87e0ef8aba62fd9bfbd5605b8.gif' style='vertical-align: middle; border: none; ' class='tex' alt="1/j" /></span><script type='math/tex'>1/j</script>）。</p>
<p>所以上面策略的成功概率为 <span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_162fba3f0bfe98f043fa4148428acf72.gif' style='vertical-align: middle; border: none; ' class='tex' alt="1-\ln 2 \sim 0.3" /></span><script type='math/tex'>1-\ln 2 \sim 0.3</script>。</p>
<p>类似于以前提到的<a href="http://zhiqiang.org/blog/science/game-one-hat.html">帽子游戏一</a>以及<a href="http://zhiqiang.org/blog/science/game-two-hats.html">帽子游戏二</a>，我们要最大化一个团体都成功的概率，但是每个单个个体成功的概率又是一定的，那么我们只需要设计策略时，让大家要么几乎同时成功，要么几乎同时失败。就像上面的策略里，如果有人失败，意味着排列中有一个长度很大（大于n/2）的圈，这个圈上所有人同时也会失败，通过把失败的实例重合到一起，这样就提高了总体成功的概率。</p>
<p>上面这个问题不是孤立的，它可以应用在static data structure problems的下界证明上。对于后面这个问题，在最近是一个很热门的研究领域，但在这里写了也没人看，知道这个问题的也不需要看，所以我只提一下我们还可以做什么，下面是一个open problem，可以直接得出一个data structure问题的一个下界，是一个可以写学术论文的题目：</p>
<blockquote><p>Open problem：假设现在有<span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_21e2c0c0472b331622877accbe29b91b.gif' style='vertical-align: middle; border: none; padding-bottom:1px;' class='tex' alt="2n" /></span><script type='math/tex'>2n</script>个箱子，<span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_7b8b965ad4bca0e41ab51de7b31363a1.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="n" /></span><script type='math/tex'>n</script>个学生，学生们的名字纸条被放入随机选中的<span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_7b8b965ad4bca0e41ab51de7b31363a1.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="n" /></span><script type='math/tex'>n</script>个箱子里。现在每个学生可以检查不超过一半也就是<span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_7b8b965ad4bca0e41ab51de7b31363a1.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="n" /></span><script type='math/tex'>n</script>个箱子，以找到含有自己名字的箱子。问这时候学生可以采取什么样的策略最大化所有学生都成功找到含有自己名字的箱子的概率。</p>
</blockquote>
<p>期望结果：证明指数级小的下界或者找到常数概率的策略。</p>
<p>有兴趣的可以参考<a href="http://cs.au.dk/~bromille/Papers/succinct.pdf" target="_blank">The cell probe complexity of succinct data structures</a>.</p>
<div><h4>相关文章</h4><ul><li><a href="http://zhiqiang.org/blog/science/the-perfect-number-of-shuffling-7-times.html">&quot;完美&quot;的洗牌次数 - 7次</a></li><li><a href="http://zhiqiang.org/blog/science/theoritical-analysis-marfia-game.html">杀人的理论分析</a></li><li><a href="http://zhiqiang.org/blog/science/computer-science/tcs-byzantine-failure-the-byzantine-generals-problem.html">TCS: 拜占庭将军问题 (The Byzantine Generals Problem)</a></li><li><a href="http://zhiqiang.org/blog/science/tcs-classroom-notes-the-best-dating-strategy.html">最佳约会策略</a></li><li><a href="http://zhiqiang.org/blog/science/computer-science/tcs-classroom-notes-database-storage-problems.html">TCS课堂笔记：数据库存储问题</a></li><li><a href="http://zhiqiang.org/blog/science/how-n-people-divide-a-cake-fairly.html">征集3个人分蛋糕的方法</a></li><li><a href="http://zhiqiang.org/blog/entertainment/fan-tan-game-empty-when-most-difficult-relationship.html">空当接龙中最难的关</a></li><li><a href="http://zhiqiang.org/blog/science/strategy-games-doctors-and-patients-i.html">策略游戏：医生和病人（I）</a></li><li><a href="http://zhiqiang.org/blog/entertainment/cat-game.html">堵猫游戏</a></li><li><a href="http://zhiqiang.org/blog/entertainment/kerrigan-starcraft-ii.html">Kerrigan！</a></li></ul></div>    <p></p>
    <hr noshade style="margin:0;height:1px" />
    <p>&copy; zhiqiang for <a href="http://zhiqiang.org/blog">阅微堂</a>, 2008. | <a href="http://zhiqiang.org/blog/science/computer-science/boxes-problem-on-static-data-structure-problems.html">&#38142;&#25509;</a> | <a href="http://zhiqiang.org/blog/science/computer-science/boxes-problem-on-static-data-structure-problems.html#comments">15 &#26465;&#35780;&#35770;</a></p>]]></content:encoded>
			<wfw:commentRss>http://zhiqiang.org/blog/science/computer-science/boxes-problem-on-static-data-structure-problems.html/feed</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>征集3个人分蛋糕的方法</title>
		<link>http://zhiqiang.org/blog/science/how-n-people-divide-a-cake-fairly.html</link>
		<comments>http://zhiqiang.org/blog/science/how-n-people-divide-a-cake-fairly.html#comments</comments>
		<pubDate>Tue, 25 Sep 2007 07:54:07 +0000</pubDate>
		<dc:creator>zhiqiang</dc:creator>
				<category><![CDATA[自然科学]]></category>
		<category><![CDATA[切蛋糕]]></category>
		<category><![CDATA[头脑风暴]]></category>
		<category><![CDATA[理论计算机笔记]]></category>

		<guid isPermaLink="false">http://zhiqiang.org/blog/posts/how-n-people-divide-a-cake-fairly.html</guid>
		<description><![CDATA[博客 » 自然科学 » 头脑风暴 » 系列：头脑风暴 查看该系列所有文章 系列：理论计算机笔记 查看该系列所有文章 Yao在课程《理论计算机II》的第一节课上提到的一个问题： 三个人如何平分一块蛋糕？ 要求每个人拿到不少于1/3的蛋糕——这里指的是每个人认为自己拿到的蛋糕价值不少于整块蛋糕的1/3，而每个人对于蛋糕的不同区域的价值认识可能不同（即并不完全等价于面...]]></description>
			<content:encoded><![CDATA[<p id="breadcrumb" class="breadcrumb"><a href="http://zhiqiang.org/blog/">博客</a> » <a href="http://zhiqiang.org/blog/category/science">自然科学</a> » <a href='http://zhiqiang.org/blog/tag/%e5%a4%b4%e8%84%91%e9%a3%8e%e6%9a%b4'>头脑风暴</a>  » </p><div class="series"><span>系列：<b>头脑风暴</b></span><br/>
<a href="http://zhiqiang.org/blog/tag/%e5%a4%b4%e8%84%91%e9%a3%8e%e6%9a%b4">查看该系列所有文章</a>
<div id='series'></div>
</div>  <div class="series"><span>系列：<b>理论计算机笔记</b></span><br/>
<a href="http://zhiqiang.org/blog/tag/%e7%90%86%e8%ae%ba%e8%ae%a1%e7%ae%97%e6%9c%ba%e7%ac%94%e8%ae%b0">查看该系列所有文章</a>
<div id='series'></div>
</div>  </p>
<p>Yao在课程《理论计算机II》的第一节课上提到的一个问题：</p>
<blockquote><p>三个人如何平分一块蛋糕？</p>
<p>要求每个人拿到不少于1/3的蛋糕——这里指的是每个人认为自己拿到的蛋糕价值不少于整块蛋糕的1/3，而每个人对于蛋糕的不同区域的价值认识可能不同（即并不完全等价于面积）。</p>
<p>方法最好可以推广到n个人的情形。</p>
</blockquote>
<p>课上讲了一种方法：</p>
<blockquote><p>任选一个人，在蛋糕上缓慢移动，直到有人喊停，切下一块给这个喊停的人。直到分完为止，最后一块给最后一个人（没机会喊停了）。</p>
</blockquote>
<p>这个有趣的问题在课堂上引起非常多的讨论，助教被要求在习题课上至少给出6种不同的方法...</p>
<p>请大家帮忙，踊跃发言 <img src='http://zhiqiang.org/blog/wp-includes/images/smilies/smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>[tags]理论计算机课程,切蛋糕,策略[/tags]</p>
<div><h4>相关文章</h4><ul><li><a href="http://zhiqiang.org/blog/science/tcs-classroom-notes-the-best-dating-strategy.html">最佳约会策略</a></li><li><a href="http://zhiqiang.org/blog/science/computer-science/tcs-byzantine-failure-the-byzantine-generals-problem.html">TCS: 拜占庭将军问题 (The Byzantine Generals Problem)</a></li><li><a href="http://zhiqiang.org/blog/science/the-perfect-number-of-shuffling-7-times.html">&quot;完美&quot;的洗牌次数 - 7次</a></li><li><a href="http://zhiqiang.org/blog/science/computer-science/tcs-classroom-notes-database-storage-problems.html">TCS课堂笔记：数据库存储问题</a></li><li><a href="http://zhiqiang.org/blog/science/computer-science/boxes-problem-on-static-data-structure-problems.html">摸箱子问题以及应用</a></li><li><a href="http://zhiqiang.org/blog/science/37-rule-is-optimal.html">37-rule-is-optimal</a></li><li><a href="http://zhiqiang.org/blog/science/rotate-coin-games.html">硬币游戏</a></li><li><a href="http://zhiqiang.org/blog/science/when-to-stop.html">何时适可而止?</a></li><li><a href="http://zhiqiang.org/blog/science/a-square-game.html">取格子游戏的构造性策略</a></li><li><a href="http://zhiqiang.org/blog/science/compute-anonymous-statistics.html">如何匿名统计平均收入</a></li></ul></div>    <p></p>
    <hr noshade style="margin:0;height:1px" />
    <p>&copy; zhiqiang for <a href="http://zhiqiang.org/blog">阅微堂</a>, 2007. | <a href="http://zhiqiang.org/blog/science/how-n-people-divide-a-cake-fairly.html">&#38142;&#25509;</a> | <a href="http://zhiqiang.org/blog/science/how-n-people-divide-a-cake-fairly.html#comments">13 &#26465;&#35780;&#35770;</a></p>]]></content:encoded>
			<wfw:commentRss>http://zhiqiang.org/blog/science/how-n-people-divide-a-cake-fairly.html/feed</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>TCS课堂笔记：数据库存储问题</title>
		<link>http://zhiqiang.org/blog/science/computer-science/tcs-classroom-notes-database-storage-problems.html</link>
		<comments>http://zhiqiang.org/blog/science/computer-science/tcs-classroom-notes-database-storage-problems.html#comments</comments>
		<pubDate>Tue, 08 May 2007 10:04:13 +0000</pubDate>
		<dc:creator>zhiqiang</dc:creator>
				<category><![CDATA[计算机科学]]></category>
		<category><![CDATA[数据结构]]></category>
		<category><![CDATA[理论计算机笔记]]></category>

		<guid isPermaLink="false">http://zhiqiang.org/blog/587.html</guid>
		<description><![CDATA[博客 » 计算机科学 » 理论计算机笔记 » 系列：理论计算机笔记 查看该系列所有文章 理论计算机(I)课上讲的一个问题，很有意思。 已经一个n，m和里n个数，设计一种保存这n个元素的表的数据结构形式，使得对中任何一个数，可以最少的查询次数（每次查询，可以选择一个位置，然后你能知道表中这个位置的数据），获知这个数是否在表中。 如果设计这个表为有序表，用二...]]></description>
			<content:encoded><![CDATA[<p id="breadcrumb" class="breadcrumb"><a href="http://zhiqiang.org/blog/">博客</a> » <a href="http://zhiqiang.org/blog/category/science/computer-science">计算机科学</a> » <a href='http://zhiqiang.org/blog/tag/%e7%90%86%e8%ae%ba%e8%ae%a1%e7%ae%97%e6%9c%ba%e7%ac%94%e8%ae%b0'>理论计算机笔记</a>  » </p><div class="series"><span>系列：<b>理论计算机笔记</b></span><br/>
<a href="http://zhiqiang.org/blog/tag/%e7%90%86%e8%ae%ba%e8%ae%a1%e7%ae%97%e6%9c%ba%e7%ac%94%e8%ae%b0">查看该系列所有文章</a>
<div id='series'></div>
</div>  <p>理论计算机(I)课上讲的一个问题，很有意思。</p>
<p>已经一个n，m和<span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_d43069858d2a796ab1b977f3684de967.gif' style='vertical-align: middle; border: none; ' class='tex' alt="\{1,2,\cdots, m\}" /></span><script type='math/tex'>\{1,2,\cdots, m\}</script>里n个数，设计一种保存这n个元素的表的数据结构形式，使得对<span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_d43069858d2a796ab1b977f3684de967.gif' style='vertical-align: middle; border: none; ' class='tex' alt="\{1,2,\cdots, m\}" /></span><script type='math/tex'>\{1,2,\cdots, m\}</script>中任何一个数，可以最少的查询次数（每次查询，可以选择一个位置，然后你能知道表中这个位置的数据），获知这个数是否在表中。</p>
<p>如果设计这个表为有序表，用二分法需要<span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_0d2e858bd7f89eed5461e5637d6e0a50.gif' style='vertical-align: middle; border: none; ' class='tex' alt="\log n" /></span><script type='math/tex'>\log n</script>次查询。</p>
<p>有序表是最优的么？</p>
<p>举一个例子，一个保存1，2，3里面的两个数的有序表，要想知道2是否在这个表里面，至少需要两次查询。可不可以用一种特定的数据结构，使得一次查询就能判定任何一个数是不是在数据库里面？</p>
<p>结论是可能的，见下图：</p>
<p align="center"><a title="sorted table" href="http://www.flickr.com/photos/51234757@N00/489673515/"><img alt="sorted table" src="http://farm1.static.flickr.com/189/489673515_9cc3702472.jpg" border="0"/></a></p>
<p>一般的，假如表里的n个数的范围是1，2，...，2n-2，即<span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_01e42101c7214aaa22d1f8fc3eeb5a15.gif' style='vertical-align: middle; border: none; padding-bottom:1px;' class='tex' alt="m=2n-2" /></span><script type='math/tex'>m=2n-2</script>，可以设计一种方法，使得，对于任何一个数，<strong>只需要查询一次</strong>，便能知道这个数是否在这个表里面。</p>
<p>课堂上有同学当场就想出设计方法，向他致敬！</p>
<p>另外，利用广义的Ramsey定理，对于固定的n，能够证明当m足够大时，无论你怎么设计那个表的结构，也至少需要<span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_0d2e858bd7f89eed5461e5637d6e0a50.gif' style='vertical-align: middle; border: none; ' class='tex' alt="\log n" /></span><script type='math/tex'>\log n</script>的查询次数。</p>
<p>一个很神奇的问题。相关论文<a href="http://www.cs.umd.edu/~gasarch/BLOGPAPERS/tables.pdf" target="_blank">Should Table be Sorted?</a>, 上面的图片也来自这篇文章。</p>
<p>[tags]数据库,理论计算机[/tags]</p>
<div><h4>相关文章</h4><ul><li><a href="http://zhiqiang.org/blog/science/computer-science/programs-depend-on-date-struct-not-algorithm.html">编程的核心是数据结构，而不是算法</a></li><li><a href="http://zhiqiang.org/blog/science/computer-science/tcs-byzantine-failure-the-byzantine-generals-problem.html">TCS: 拜占庭将军问题 (The Byzantine Generals Problem)</a></li><li><a href="http://zhiqiang.org/blog/science/the-perfect-number-of-shuffling-7-times.html">&quot;完美&quot;的洗牌次数 - 7次</a></li><li><a href="http://zhiqiang.org/blog/science/tcs-classroom-notes-the-best-dating-strategy.html">最佳约会策略</a></li><li><a href="http://zhiqiang.org/blog/science/how-n-people-divide-a-cake-fairly.html">征集3个人分蛋糕的方法</a></li><li><a href="http://zhiqiang.org/blog/science/computer-science/boxes-problem-on-static-data-structure-problems.html">摸箱子问题以及应用</a></li></ul></div>    <p></p>
    <hr noshade style="margin:0;height:1px" />
    <p>&copy; zhiqiang for <a href="http://zhiqiang.org/blog">阅微堂</a>, 2007. | <a href="http://zhiqiang.org/blog/science/computer-science/tcs-classroom-notes-database-storage-problems.html">&#38142;&#25509;</a> | <a href="http://zhiqiang.org/blog/science/computer-science/tcs-classroom-notes-database-storage-problems.html#comments">6 &#26465;&#35780;&#35770;</a></p>]]></content:encoded>
			<wfw:commentRss>http://zhiqiang.org/blog/science/computer-science/tcs-classroom-notes-database-storage-problems.html/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>最佳约会策略</title>
		<link>http://zhiqiang.org/blog/science/tcs-classroom-notes-the-best-dating-strategy.html</link>
		<comments>http://zhiqiang.org/blog/science/tcs-classroom-notes-the-best-dating-strategy.html#comments</comments>
		<pubDate>Sat, 10 Mar 2007 12:00:37 +0000</pubDate>
		<dc:creator>zhiqiang</dc:creator>
				<category><![CDATA[自然科学]]></category>
		<category><![CDATA[头脑风暴]]></category>
		<category><![CDATA[理论计算机笔记]]></category>
		<category><![CDATA[生活中的数学]]></category>

		<guid isPermaLink="false">http://zhiqiang.org/blog/534.html</guid>
		<description><![CDATA[博客 » 自然科学 » 头脑风暴 » 系列：头脑风暴 查看该系列所有文章 系列：理论计算机笔记 查看该系列所有文章 系列：生活中的数学 查看该系列所有文章 题外话：最近阅微堂发的都是网友转发的政治方面的文章，不爱看的人会比较痛苦。现在讨论一个轻松一点的话题。其问题，已经被研究了很多年，有许多不同形式的阐述方式和变种，应用范围也很广。下面应该是比较吸...]]></description>
			<content:encoded><![CDATA[<p id="breadcrumb" class="breadcrumb"><a href="http://zhiqiang.org/blog/">博客</a> » <a href="http://zhiqiang.org/blog/category/science">自然科学</a> » <a href='http://zhiqiang.org/blog/tag/%e5%a4%b4%e8%84%91%e9%a3%8e%e6%9a%b4'>头脑风暴</a>  » </p><div class="series"><span>系列：<b>头脑风暴</b></span><br/>
<a href="http://zhiqiang.org/blog/tag/%e5%a4%b4%e8%84%91%e9%a3%8e%e6%9a%b4">查看该系列所有文章</a>
<div id='series'></div>
</div>  <div class="series"><span>系列：<b>理论计算机笔记</b></span><br/>
<a href="http://zhiqiang.org/blog/tag/%e7%90%86%e8%ae%ba%e8%ae%a1%e7%ae%97%e6%9c%ba%e7%ac%94%e8%ae%b0">查看该系列所有文章</a>
<div id='series'></div>
</div>  <div class="series"><span>系列：<b>生活中的数学</b></span><br/>
<a href="http://zhiqiang.org/blog/tag/%e7%94%9f%e6%b4%bb%e4%b8%ad%e7%9a%84%e6%95%b0%e5%ad%a6">查看该系列所有文章</a>
<div id='series'></div>
</div>  <p>题外话：最近<a href="http://zhiqiang.org/blog/">阅微堂</a>发的都是网友转发的政治方面的文章，不爱看的人会比较痛苦。现在讨论一个轻松一点的话题。其问题，已经被研究了很多年，有许多不同形式的阐述方式和变种，应用范围也很广。下面应该是比较吸引人和简单的那种，来自<a href="http://itcs.tsinghua.edu.cn/yao" target="_blank">姚期智</a>教授的理论计算机（I）的授课内容——我是其助教之一。</p>
<hr />
<p>现假设你在PIE上征友，或者以其它方式，选定了某些约会对象，比如<span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_7774fee0a1a510739aba1724f7498361.gif' style='vertical-align: middle; border: none; padding-bottom:1px;' class='tex' alt="n=20" /></span><script type='math/tex'>n=20</script>个。约会当然得一个一个来，那么假设</p>
<ol>
<li>可以将所有已约会的对象按优劣排序，但无法得知他们在所有的人里面的排名。在约会过程中，你知道某人是你目前已见到的最好的，但当时还不能确定是不是所有人里面最好的。  </li>
<li>如果你在约会当时决定放弃某人，后面再没有机会和此人和好——好马不吃回头草。  </li>
<li>选定意中人后，约会结束——骑驴找马是不道德的。</li>
</ol>
<p>OK，现在目标当然是找到你心目中最喜欢的人。关系定得太早，会因为第2条假设——精彩的还在后头，定得太晚，会因为第3条——而后悔莫及。所以，什么策略才能让你以最大概率找到你最满意的那个人呢？</p>
<p>一个简单而且自然的方法是，待定<span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_8ce4b16b22b58894aa86c421e8759df3.gif' style='vertical-align: middle; border: none; padding-bottom:1px;' class='tex' alt="k" /></span><script type='math/tex'>k</script>，<font color="#ff0000">与前<span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_8ce4b16b22b58894aa86c421e8759df3.gif' style='vertical-align: middle; border: none; padding-bottom:1px;' class='tex' alt="k" /></span><script type='math/tex'>k</script>个人约会，不做任何选择。继续约会直到遇到比这前k个人还好的那个人为止</font>。</p>
<p>通过概率计算得出，这个方法比我们想象中要好得多。通过选取合适的<font color="#ff0000"><span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_13d4936d53a62125c461befff421b39d.gif' style='vertical-align: middle; border: none; ' class='tex' alt="k=n/e\sim 0.37n\sim 7" /></span><script type='math/tex'>k=n/e\sim 0.37n\sim 7</script></font>，有接近<font color="#ff0000">40%</font>的机会选中最好的那位，有几乎70%的机会选中最好或者次好的那位。</p>
<p>可以证明，上面的策略已经是最优的了。（证明在此：<a href="http://zhiqiang.org/blog/science/37-rule-is-optimal.html">37 rule is optimal</a>，英文）。</p>
<p>这个问题在日常生活中有更多应用。比如你打算在30岁前结婚，现在20岁。那么在24岁前先别确定目标，24岁以后遇到比之前都好的就可以定下来。这几乎就是你能达到最好的结果了——假设你的候选人在这十年是均匀或者随机出现的。</p>
<p>这种策略也许能说明为何初恋成功率低？</p>
<p>以上所用都是爱情和婚姻的简化模型，没有考虑爱情中的主观因素。所以，请<font color="#ff0000">只把它当作一个脑力游戏</font>。</p>
<div><h4>相关文章</h4><ul><li><a href="http://zhiqiang.org/blog/science/how-n-people-divide-a-cake-fairly.html">征集3个人分蛋糕的方法</a></li><li><a href="http://zhiqiang.org/blog/science/computer-science/tcs-byzantine-failure-the-byzantine-generals-problem.html">TCS: 拜占庭将军问题 (The Byzantine Generals Problem)</a></li><li><a href="http://zhiqiang.org/blog/science/the-perfect-number-of-shuffling-7-times.html">&quot;完美&quot;的洗牌次数 - 7次</a></li><li><a href="http://zhiqiang.org/blog/science/computer-science/tcs-classroom-notes-database-storage-problems.html">TCS课堂笔记：数据库存储问题</a></li><li><a href="http://zhiqiang.org/blog/science/computer-science/boxes-problem-on-static-data-structure-problems.html">摸箱子问题以及应用</a></li><li><a href="http://zhiqiang.org/blog/science/how-should-the-money.html">钱应该怎么分？</a></li><li><a href="http://zhiqiang.org/blog/science/theoritical-analysis-marfia-game.html">杀人的理论分析</a></li><li><a href="http://zhiqiang.org/blog/science/how-to-gamble-optimally.html">赌博的最优策略</a></li><li><a href="http://zhiqiang.org/blog/science/buy-car-in-beijing.html">北京摇中号有多难</a></li><li><a href="http://zhiqiang.org/blog/science/how-to-gamble-if-you-in-hurry.html">赌博的最优策略(II)</a></li></ul></div>    <p></p>
    <hr noshade style="margin:0;height:1px" />
    <p>&copy; zhiqiang for <a href="http://zhiqiang.org/blog">阅微堂</a>, 2007. | <a href="http://zhiqiang.org/blog/science/tcs-classroom-notes-the-best-dating-strategy.html">&#38142;&#25509;</a> | <a href="http://zhiqiang.org/blog/science/tcs-classroom-notes-the-best-dating-strategy.html#comments">27 &#26465;&#35780;&#35770;</a></p>]]></content:encoded>
			<wfw:commentRss>http://zhiqiang.org/blog/science/tcs-classroom-notes-the-best-dating-strategy.html/feed</wfw:commentRss>
		<slash:comments>27</slash:comments>
		</item>
		<item>
		<title>&quot;完美&quot;的洗牌次数 - 7次</title>
		<link>http://zhiqiang.org/blog/science/the-perfect-number-of-shuffling-7-times.html</link>
		<comments>http://zhiqiang.org/blog/science/the-perfect-number-of-shuffling-7-times.html#comments</comments>
		<pubDate>Fri, 15 Dec 2006 04:23:51 +0000</pubDate>
		<dc:creator>zhiqiang</dc:creator>
				<category><![CDATA[自然科学]]></category>
		<category><![CDATA[Diaconis]]></category>
		<category><![CDATA[概率]]></category>
		<category><![CDATA[洗牌]]></category>
		<category><![CDATA[理论计算机笔记]]></category>
		<category><![CDATA[随机算法]]></category>
		<category><![CDATA[魔术]]></category>

		<guid isPermaLink="false">http://zhiqiang.org/blog/498.html</guid>
		<description><![CDATA[博客 » 自然科学 » 概率 » 系列：理论计算机笔记 查看该系列所有文章 在大家玩牌的时候，每一局之前都需要重新洗牌——一次洗牌指将牌分为左右两垛然后穿插放牌，但多少次洗牌才是正当的呢？就我多次打牌的观察，多数人都不超过4次。 但就D. Aldous和P. Diaconis在1992的一个结果，要想达到“比较完美”的洗牌效果——洗完牌后牌局基本上随机分布，至少需要5次，要达到...]]></description>
			<content:encoded><![CDATA[<p id="breadcrumb" class="breadcrumb"><a href="http://zhiqiang.org/blog/">博客</a> » <a href="http://zhiqiang.org/blog/category/science">自然科学</a> » <a href='http://zhiqiang.org/blog/tag/%e6%a6%82%e7%8e%87'>概率</a>  » </p><div class="series"><span>系列：<b>理论计算机笔记</b></span><br/>
<a href="http://zhiqiang.org/blog/tag/%e7%90%86%e8%ae%ba%e8%ae%a1%e7%ae%97%e6%9c%ba%e7%ac%94%e8%ae%b0">查看该系列所有文章</a>
<div id='series'></div>
</div>  <p>在大家玩牌的时候，每一局之前都需要重新洗牌——一次洗牌指将牌分为左右两垛然后穿插放牌，但多少次洗牌才是正当的呢？就我多次打牌的观察，多数人都不超过4次。</p>
<p>但就D. Aldous和P. Diaconis<a href="http://www.dartmouth.edu/~chance/course/topics/winning_number.html" target="_blank">在1992的一个结果</a>，要想达到“比较完美”的洗牌效果——洗完牌后牌局基本上随机分布，至少需要5次，要达到“完美”洗牌，则需要7次。但更多次数不会有太多改进。这还是对于一副牌而言的。对于两副牌则需要9次，6副牌需要洗12次。</p>
<p>所用方法是计算图上随机游走达到稳定分布的速度。而这个方法就应用于上面这个结果之后，对于理论计算机的概率算法产生了深远的影响，这也使得P.Diaconis的<a href="http://www.dartmouth.edu/~chance/teaching_aids/books_articles/Mann.pdf" target="_blank">这篇论文</a>超出了它本身看似玩物的领域。</p>
<p>再谈一下<a href="http://www-stat.stanford.edu/~cgates/PERSI/" target="_blank">P. Diaconis</a>，此君14岁离家，去做职业魔术师，没上高中，后来用白天魔术表演挣来的钱晚上念大学课程，最后获得哈佛的博士和斯坦福的教职。另传说中，此人赌技惊人，是赌场不受欢迎之人物。</p>
<div><h4>相关文章</h4><ul><li><a href="http://zhiqiang.org/blog/science/computer-science/boxes-problem-on-static-data-structure-problems.html">摸箱子问题以及应用</a></li><li><a href="http://zhiqiang.org/blog/science/mathmatics-in-rubik-cube-and-algorithm.html">魔方里的数学</a></li><li><a href="http://zhiqiang.org/blog/resource/magics-in-2009-spring-festival-gala.html">2009年的春节晚会魔术</a></li><li><a href="http://zhiqiang.org/blog/science/computer-science/tcs-byzantine-failure-the-byzantine-generals-problem.html">TCS: 拜占庭将军问题 (The Byzantine Generals Problem)</a></li><li><a href="http://zhiqiang.org/blog/science/tcs-classroom-notes-the-best-dating-strategy.html">最佳约会策略</a></li><li><a href="http://zhiqiang.org/blog/science/computer-science/tcs-classroom-notes-database-storage-problems.html">TCS课堂笔记：数据库存储问题</a></li><li><a href="http://zhiqiang.org/blog/science/how-n-people-divide-a-cake-fairly.html">征集3个人分蛋糕的方法</a></li><li><a href="http://zhiqiang.org/blog/science/three-doors-related-problems.html">三门问题及相关</a></li><li><a href="http://zhiqiang.org/blog/science/test-on-probability.html">概率论感觉测试</a></li><li><a href="http://zhiqiang.org/blog/science/when-to-stop.html">何时适可而止?</a></li></ul></div>    <p></p>
    <hr noshade style="margin:0;height:1px" />
    <p>&copy; zhiqiang for <a href="http://zhiqiang.org/blog">阅微堂</a>, 2006. | <a href="http://zhiqiang.org/blog/science/the-perfect-number-of-shuffling-7-times.html">&#38142;&#25509;</a> | <a href="http://zhiqiang.org/blog/science/the-perfect-number-of-shuffling-7-times.html#comments">6 &#26465;&#35780;&#35770;</a></p>]]></content:encoded>
			<wfw:commentRss>http://zhiqiang.org/blog/science/the-perfect-number-of-shuffling-7-times.html/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

