查看: 11323| 回复: 46
跳转到指定楼层
上一主题 下一主题
收起左侧

Stanford Design and Analysis of Algorithm I 第二期 Week#3 自由讨论

 关闭
全局:
Topic:


1. VII --- We've posted a second part of the probability review. It's pretty short, just two topics, although quite tricky ones! (Namely, conditional probability and independence.) You need to review this material (via this video or some other source, as you wish) before studying the analysis of the randomized contraction algorithm (see below).


2. VIII --- Linear-Time Selection (Required). These lectures study the problem of computing the ith smallest element of an input array (e.g., the median). It's easy to solve this problem in O(n log n) time using sorting, but we can do better! The required material goes over a super-practical randomized algorithm, very much in the spirit of QuickSort, that has *linear* expected running time. Don't forget that it takes linear time just to read the input! The analysis is somewhat different than what we studied for QuickSort, but is equally as slick. Basically, there's a cool way to think about the progress the algorithm makes in terms of a simple coin-flipping experiment. Linearity of expectation (yes, it's back...) seals the deal.

3. VIII --- Linear-Time Selection (Optional). I couldn't resist covering some advanced related material. The first is an algorithm that has more Turing Award-winning authors than any other algorithm that I know of. It is a deterministic (i.e., no randomization allowed) linear-time algorithm for the Selection problem, based on an ingenious "median-of-medians" idea for guaranteeing good pivot choices. The second optional topic answers the question "can we do better?" for sorting, unfortunately in the negative. That is, a counting argument shows that there is no "comparison-based" sorting algorithm (like MergeSort, QuickSort, or HeapSort) with worst-case running time better than n log n.

4. IX --- Graphs and the Contraction Algorithm. The second set of lectures for this week is a segue from randomized algorithms to graph algorithms. We first review graphs and the most standard ways of representing them (most commonly, by adjacency lists). We then consider the random contraction algorithm, discovered by Karger "only" 20 years ago (while a PhD student here at Stanford). This algorithm solves the minimum cut problem --- given an undirected graph, separate the vertices into two non-empty groups to minimize the number of "crossing edges". Such problems come up when reasoning about, for example, physical networks, social networks, and images. This algorithm was perhaps the first strong evidence that graph problems could be added to the long list of "killer applications" of random sampling. Don't tune out before the final plot twist --- a simple but useful trick for transforming an algorithm that almost always fails into one that almost always succeeds.


Homework:5.


Problem Set #3 has five questions about the randomized selection algorithm, cuts in graphs, and the contraction algorithm. As usual, it's due in a little less than two weeks, and if you miss the deadline you can turn it in by the end of the course for half credit (August 5th).

6. Programming Project #3 asks you to implement the contraction algorithm and use it to compute the min cut of the graph that we provide.

7. I posted the second batch of 5 optional theory problems, on the topics of sorting lower bounds, linear-time selection, and min cuts. It was great to see some healthy discussion of the first batch on the forums, and I hope it continues with this new batch!
单选投票, 共有 43 人参与投票
97.67% (42)
2.33% (1)
您所在的用户组没有投票权限

上一篇:Udacity 今天也有一门算法课出来,应该比stanford的简单不少
下一篇:Stanford Design and Analysis of Algorithm I 第二期 Week#4 自由讨论
🔗
EDream 2012-6-28 13:47:58 | 只看该作者
全局:
头一次接触graph的概念不是很适应 ,刚把problem set的5道题目做完,花了很长时间。Question2有个疑问:Lecture中的证明是对于every Graph with n vertices and every min cut of G这个适用范围的,因此两个>=的选项是可选的;但是,对于第三个正确选项There exists a graph G with n nodes and a min cut (A,B) of G such that Pr[out=(A,B)]≤p.不是很理解,我觉得这属于lecture证明中的特殊情况,Pr[out=(A,B)]依旧应当>=p,想知道为什么答案是正确的呢?
回复

使用道具 举报

🔗
endless 2012-6-28 22:27:00 | 只看该作者
全局:
请教大家一下最后一个video中,老师证明了对于n个节点的图,最大可能的min cut数量是(n取2)。老师的证法是先证明lower bound,再证明upper bound。想知道为啥要这么证明?就一个upper bound不就ok了吗?
回复

使用道具 举报

🔗
endless 2012-6-28 22:44:09 | 只看该作者
全局:
这个回复贴错地方了。。。应该放在第三周的帖子的。现在挪过来:

---------------------------------------------------

有个关于时间复杂度的问题请教一下大家。

merge_sort的时间复杂度,在每种情况下都是O(nlogn),而randomized_quick_sort仅是在平均情况下达到O(nlogn),从这个分析来看,似乎merge_sort要比randomized_quick_sort更“快”。但实际并非这样。

排序这个是上周讲的了,但这个问题在本周的selection里面又有类似的情况,就是R_selection也只是在平均时间上达到O(n),optional视频中的deterministic的selection算法能在每种情况下都达到O(n),但视频中也提到在平时使用中,仍然是R_selection更快一些。

这是为啥呢?网上搜了点相关的文章,大多说法是因为会牵扯到被big-Oh notation所隐去的constant,还有算法是否in-place也有关系。randomized的算法,最坏情况极少极少出现,又因为算法时间中的constant较小,所以更快。非randomized算法虽然在每种情况下都能保证某个渐进时间复杂度,但由于不是in-place,算法时间的constant又较大,所以反而更慢。

觉得还需要个比较系统和全面的分析。在实际应用中,有算法使用经验的人应该有点感触。恳请大侠们出来说说看法~

---------------------------------------------------
回复

使用道具 举报

🔗
endless 2012-6-28 23:16:46 | 只看该作者
全局:
EDream 发表于 2012-6-28 13:47
头一次接触graph的概念不是很适应 ,刚把problem set的5道题目做完,花了很长时间。Question2有个疑问:Lec ...

注意题目中的措辞。说的“存在”,there exists,也就是说,存在一种图形,生成某个min cut的概率小于p。那么对于这个,我们只要举出一个符合的例子就可以了。考虑n-cycle的那种图形,min cut有(choose 2 from n)种,而总共的cut数量大于这个,因此总体概率小于p。
回复

使用道具 举报

🔗
EDream 2012-6-29 16:15:29 | 只看该作者
全局:
endless 发表于 2012-6-28 22:27
请教大家一下最后一个video中,老师证明了对于n个节点的图,最大可能的min cut数量是(n取2)。老师的证法是 ...

要证明的是The largest number of min cuts,假设它是A,如果求出lower和upper bounds, 使lower <= A <= upper,逼近后就得出了所要求的A了,两个边界都是需要的。

补充个问题:关于n-cycle依旧不是很懂,为啥对于它来说, 存在min cuts >= n choose 2呢? 我觉得n-cycle总共的cuts只有n choose 2(任意取其中的两个edge),而这些也都是min cuts。

回复

使用道具 举报

🔗
EDream 2012-6-29 16:25:49 | 只看该作者
全局:
endless 发表于 2012-6-28 23:16
注意题目中的措辞。说的“存在”,there exists,也就是说,存在一种图形,生成某个min cut的概率小于p。 ...

可是Lecture中的证明是对于任意一个图形中的任意一个min cut,生成的概率>=p (1/n choose 2)
而现在这个概率<=p的结论是不是和前面的论证矛盾呢?
回复

使用道具 举报

🔗
endless 2012-6-29 18:05:43 | 只看该作者
全局:
本帖最后由 endless 于 2012-7-18 11:20 编辑
EDream 发表于 2012-6-29 16:15
要证明的是The largest number of min cuts,假设它是A,如果求出lower和upper bounds, 使lower

其实这里涉及到cut的定义问题。我看Wiki上说是:In graph theory, a cut is a partition of the vertices of a graph into two disjoint subsets.是根据节点来分成两个组,lecture里面也是这么说的。

那么这两个部分,各自是否一定是连通的?没找到相关的内容,我也比较疑惑。但在Wiki页面上的maximum cut里面看到,最大割的情况下,一个graph被分成了>2个不连通的部分。在lecture里面也提到,一个graph的最大cut数量大概是2^n个,n是节点数。

min cut的数量,对于环形来说是n choose 2(实际上是m choose 2,m是边数,在环形图中n = m,n是节点数)。总cut的数量我也疑惑了,例如,是否如下情况也算作一个cut:四个节点的环形图(正方形的样子),对角的两个点分到一起,这样一cut,cut过后的图形就各自不连通了。

如果上述也算cut,那么环形图的总cut就不止n choose 2个了。
回复

使用道具 举报

🔗
endless 2012-6-29 18:42:28 | 只看该作者
全局:
EDream 发表于 2012-6-29 16:25
可是Lecture中的证明是对于任意一个图形中的任意一个min cut,生成的概率>=p (1/n choose 2)
而现在这个 ...

这个我也没想出来。我又突然想到,对于环形图,contraction algorithm好像每次都能输出min cut啊(有大侠举出反例不?)。。。这个题目是明确说了用这个算法得出min cut的。这样来看,对于一个fix的min cut,概率就是1/n choose 2,难道答案是因为<=中取那个=?
回复

使用道具 举报

🔗
EDream 2012-6-29 23:08:11 | 只看该作者
全局:
endless 发表于 2012-6-29 18:05
其实这里涉及到cut的定义问题。我看Wiki上说是:In graph theory, a cut is a partition of the vertices ...

如定义所说的,into two disjoint subsets,如果两个对角vertices作为一个subset,加上另外两个对角verticle就是3个subsets了,根据定义,这就不能被称为cut了。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册账号
隐私提醒:
  • ☑ 禁止发布广告,拉群,贴个人联系方式:找人请去🔗同学同事飞友,拉群请去🔗拉群结伴,广告请去🔗跳蚤市场,和 🔗租房广告|找室友
  • ☑ 论坛内容在发帖 30 分钟内可以编辑,过后则不能删帖。为防止被骚扰甚至人肉,不要公开留微信等联系方式,如有需求请以论坛私信方式发送。
  • ☑ 干货版块可免费使用 🔗超级匿名:面经(美国面经、中国面经、数科面经、PM面经),抖包袱(美国、中国)和录取汇报、定位选校版
  • ☑ 查阅全站 🔗各种匿名方法

本版积分规则

>
快速回复 返回顶部 返回列表