5.1 「THE MASTER METHOD」Overview

THE MASTER METHOD- These lectures cover a "black-box" method for solving recurrences. You can then immediately determine the running time of most of the divide-and-conquer algorithms that you'll ever see! (Including Karatsuba's integer multiplication algorithm and Strassen's matrix multiplication algorithm from Week 1.) The proof is a nice generalization of the recursion tree method that we used to analyze MergeSort. Ever wonder about the mysterious three cases of the Master Method? Watch these videos and hopefully all will become clear.

QUICKSORT - THE ALGORITHM- One of the greatest algorithms ever, and our first example of a randomized algorithm. These lectures go over the pseudocode --- the high-level approach, how to partition an array around a pivot element in linear time with minimal extra storage, and the ramifications of different pivot choices --- and explain how the algorithm works.

QUICKSORT - THE ANALYSIS-These lectures are optional, but I strongly encourage you to watch them if you have time. They prove that randomized QuickSort (i.e., with random pivot choices) runs in O(n log n) time on average. The analysis is as elegant as the algorithm itself, and is based on a "decomposition principle" that is often useful in the analysis of randomized algorithms. Note that there are some accompanying lectures notes for this part (available for download underneath each video).

PROBABILITY REVIEW- This first of these optional lecture videos reviews the concepts from discrete probability that are necessary for the QuickSort analysis --- sample spaces, events, random variables, expectation, and linearity of expectation. The second video covers 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 in Week 3.

HOMEWORK: Problem Set #2 has five questions that should give you practice with the Master Method and help you understand QuickSort more deeply. Programming Assignment #2 asks you to implement QuickSort and compute the number of comparisons that it makes for three different pivot rules.

RELATED READINGS:?Algorithms Illuminated (Part 1), Chapters 4 and 5.

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末宅荤,一起剝皮案震驚了整個濱河市挖藏,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌,老刑警劉巖媒区,帶你破解...
    沈念sama閱讀 218,607評論 6 507
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件稻艰,死亡現(xiàn)場離奇詭異,居然都是意外死亡巷查,警方通過查閱死者的電腦和手機歌馍,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,239評論 3 395
  • 文/潘曉璐 我一進店門握巢,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人松却,你說我怎么就攤上這事暴浦。” “怎么了晓锻?”我有些...
    開封第一講書人閱讀 164,960評論 0 355
  • 文/不壞的土叔 我叫張陵肉渴,是天一觀的道長。 經(jīng)常有香客問我带射,道長同规,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 58,750評論 1 294
  • 正文 為了忘掉前任窟社,我火速辦了婚禮券勺,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘灿里。我一直安慰自己关炼,他們只是感情好,可當我...
    茶點故事閱讀 67,764評論 6 392
  • 文/花漫 我一把揭開白布匣吊。 她就那樣靜靜地躺著儒拂,像睡著了一般。 火紅的嫁衣襯著肌膚如雪色鸳。 梳的紋絲不亂的頭發(fā)上社痛,一...
    開封第一講書人閱讀 51,604評論 1 305
  • 那天,我揣著相機與錄音命雀,去河邊找鬼蒜哀。 笑死,一個胖子當著我的面吹牛吏砂,可吹牛的內(nèi)容都是我干的撵儿。 我是一名探鬼主播,決...
    沈念sama閱讀 40,347評論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼狐血,長吁一口氣:“原來是場噩夢啊……” “哼淀歇!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起匈织,我...
    開封第一講書人閱讀 39,253評論 0 276
  • 序言:老撾萬榮一對情侶失蹤浪默,失蹤者是張志新(化名)和其女友劉穎,沒想到半個月后,有當?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體浴鸿,經(jīng)...
    沈念sama閱讀 45,702評論 1 315
  • 正文 獨居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 37,893評論 3 336
  • 正文 我和宋清朗相戀三年弦追,在試婚紗的時候發(fā)現(xiàn)自己被綠了岳链。 大學時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點故事閱讀 40,015評論 1 348
  • 序言:一個原本活蹦亂跳的男人離奇死亡劲件,死狀恐怖掸哑,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情零远,我是刑警寧澤苗分,帶...
    沈念sama閱讀 35,734評論 5 346
  • 正文 年R本政府宣布,位于F島的核電站牵辣,受9級特大地震影響摔癣,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜纬向,卻給世界環(huán)境...
    茶點故事閱讀 41,352評論 3 330
  • 文/蒙蒙 一择浊、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧逾条,春花似錦琢岩、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,934評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至吃警,卻和暖如春糕篇,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背酌心。 一陣腳步聲響...
    開封第一講書人閱讀 33,052評論 1 270
  • 我被黑心中介騙來泰國打工娩缰, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留,地道東北人谒府。 一個月前我還...
    沈念sama閱讀 48,216評論 3 371
  • 正文 我出身青樓拼坎,卻偏偏與公主長得像,于是被迫代替她去往敵國和親完疫。 傳聞我的和親對象是個殘疾皇子泰鸡,可洞房花燭夜當晚...
    茶點故事閱讀 44,969評論 2 355