MIT麻省理工学院 算法导论公开课Problem Set 1
IntroductiontoAlgorithmsSeptember7,2005MassachusettsInstituteofTechnology6.046J/18.410JProfessorsErikD.DemaineandCharlesE.LeisersonHandout52Handout5:ProblemSet1
(a)
(b)
(c)
(d)and(notethelittle-)
(e)and
Problem1-2.Recurrences
Giveasymptoticupperandlowerboundsforineachofthefollowingrecurrences.Assumethatisconstantfor.Makeyourboundsastightaspossible,andjustifyyouranswers.
(a)
(b)
(c)
(d)Handout5:ProblemSet13
Figure1:Anexampleofaconvexpolygonrepresentedbythearray.isthevertexwiththeminimum-coordinate,andareorderedcounterclockwise.
(b)Giveanalgorithmtofindthevertexwiththemaximumcoordinateintime.
(c)Giveanalgorithmtofindthevertexwiththemaximumcoordinateintime.
算法导论答案 (4)
未知驱动探索,专注成就专业
1
算法导论答案
第一章:算法概述
啊算法的定义
算法是一系列解决问题的明确指令。它是一个有穷步骤集,其中每个步骤或操作由确定性和可行性特征。算法是通过将预期的输入转换为输出来解决问题的工具。
第二章:插入排序
插入排序的思想
插入排序是一种简单直观的排序算法,其基本思想是将待排序的序列分为已排序和未排序两部分,每次从未排序的部分中取出一个元素,并将其插入到已排序部分的正确位置,直到所有元素都被排序。
插入排序的算法实现
以下是插入排序的伪代码:
INSERTION-SORT(A)
for j = 2 to A.length 未知驱动探索,专注成就专业
2
key = A[j]
// Insert A[j] into the sorted sequence A[1..j-1].
i = j - 1
while i > 0 and A[i] > key
A[i + 1] = A[i]
i = i - 1
A[i + 1] = key
插入排序的时间复杂度
插入排序的时间复杂度为O(n^2),其中n是排序的元素个数。虽然插入排序的最坏情况下的复杂度很高,但是对于小规模的数据集,插入排序是一种较快的排序算法。
第三章:分治策略
分治策略的基本思想
分治策略是一种解决问题的思想,它将问题的规模不断缩小,直到问题足够小而可以直接解决。然后将子问题的解合并起来,得到原问题的解。 未知驱动探索,专注成就专业
3
分治策略的应用实例
一种经典的应用分治策略的算法是归并排序。归并排序将待排序的序列划分为两个子序列,分别排序后再将两个有序子序列合并为一个有序序列。
以下是归并排序的伪代码:
MERGE-SORT(A, p, r)
if p < r
q = floor((p + r) / 2)
MERGE-SORT(A, p, q)
算法导论 第三版 第26章 答案 英
Chapter26
MichelleBodnar,AndrewLohr
April12,2016
Exercise26.1-1
Toseethatthenetworkshavethesamemaximumflow,wewillshowthat
everyflowthroughoneofthenetworkscorrespondstoaflowthroughtheother.
First,supposethatwehavesomeflowthroughthenetworkbeforeapplyingthe
splittingproceduretotheanti-symmetricedges.Sinceweareonlychanging
oneofanypairofanti-symmetricedges,foranyedgethatisunchangedbythe
splitting,wejusthaveanidenticalflowgoingthroughthoseedges.Suppose
thattherewassomeedge(u,v)thatwassplitbecauseithadananti-symmetric
edge,andwehadsomeflow,f(u,v)intheoriginalgraph.Sincethecapacityof
bothofthetwoedgesthatareintroducedbythesplittingofthatedgehavethe
samecapacity,wecansetf(u,v)=f(u,x)=f(x,v).Byconstructingthe
newflowinthismanor,wehaveanidenticaltotalflow,andwealsostillhavea
validflow.
Similarly,supposethatwehadsomeflowfonthegraphwithsplitedges,
算法导论课程作业答案
算法导论课程作业答案
Introduction to Algorithms
Massachusetts Institute of Technology 6.046J/18.410J
Singapore-MIT Alliance SMA5503 Professors Erik Demaine,Lee
Wee Sun,and Charles E.Leiserson Handout10
Diagnostic Test Solutions
Problem1
Consider the following pseudocode:
R OUTINE(n)
1if n=1
2then return1
3else return n+R OUTINE(n?1)
(a)Give a one-sentence description of what R
OUTINE(n)does.(Remember,don’t guess.) Solution:The routine
gives the sum from1to n.
(b)Give a precondition for the routine to work correctly.
Solution:The value n must be greater than0;otherwise,the
routine loops forever.
(c)Give a one-sentence description of a faster
implementation of the same routine. Solution:Return the value
n(n+1)/2.
Problem2
Give a short(1–2-sentence)description of each of the
following data structures:
(a)FIFO queue
算法导论课程考试
IntroductiontoAlgorithmsDecember17,2001
MassachusettsInstituteofTechnology6.046J/18.410J
Singapore-MITAllianceSMA5503
ProfessorsErikDemaine,LeeWeeSun,andCharlesE.LeisersonFinalExamReview
FinalExamReview
True-falsequestions
(1)TFThebestcaserunningtimeforINSERTIONSORTtosortannelementarrayisO(n).
(2)TFBythemastertheorem,thesolutiontotherecurrenceT(n)=3T(n/3)+lognis
T(n)=Θ(nlogn).
(3)TFGivenanybinarytree,wecanprintitselementsinsortedorderinO(n)timebyper-
forminganinordertreewalk.
(4)TFComputingthemedianofnelementstakesΩ(nlogn)timeforanyalgorithmworking
inthecomparison-basedmodel.
(5)TFEverybinarysearchtreeonnnodeshasheightO(logn).
(6)TFGivenagraphG=(V,E)withcostonedgesandasetS⊆V,let(u,v)beanedge
suchthat(u,v)istheminimumcostedgebetweenanyvertexinSandanyvertexinV−S.
Then,theminimumspanningtreeofGmustincludetheedge(u,v).(Youmayassumethe
MIT麻省理工学院 算法导论公开课 Problem Set 4 solution
Introduction to Algorithms October 29, 2005
Massachusetts Institute of Technology 6.046J/18.410J
Professors Erik D. Demaine and Charles E. Leiserson Handout 18
Problem Set 4 Solutions
Problem 4-1. Treaps
If we insert a set of n items into a binary search tree using TREE-INSERT, the resulting tree may
be horribly unbalanced. As we saw in class, however, we expect randomly built binary search
trees to be balanced. (Precisely, a randomly built binary search tree has expected height O(lg n).)
Therefore, if we want to build an expected balanced tree for a fixed set of items, we could randomly
permute the items and then insert them in that order into the tree.
What if we do not have all the items at once? If we receive the items one at a time, can we still
randomly build a binary search tree out of them?
We will examine a data structure that answers this question in the affirmative. A treap is a binary
算法导论习题答案 (1)
Introduction to Algorithms September 24, 2004
Massachusetts Institute of Technology 6.046J/18.410J
Professors Piotr Indyk and Charles E. Leiserson Handout 7
Problem Set 1 Solutions
Exercise 1-1. Do Exercise 2.3-7 on page 37 in CLRS.
Solution:
The following algorithm solves the problem:
1.Sort the elements in Susing mergesort.
2.Remove the last element from S. Let ybe the value of the removed element.
3.If Sis nonempty, look for z= x− yin Susing binary search.
4.If Scontains such an element z, then STOP, since we have found yand zsuch that x= y+ z.
Otherwise, repeat Step 2.
5.If Sis empty, then no two elements in Ssum to x.
Notice that when we consider an element yi of Sduring ith iteration, we don’t need to look at the
elements that have already been considered in previous iterations. Suppose there exists yj ∗ S,
ps1
IntroductiontoAlgorithmsMassachusettsInstituteofTechnologyProfessorsErikD.DemaineandCharlesE.LeisersonHandout5
Exercise1-1.DoExercise2.3-6onpage37inCLRS.
Exercise1-2.DoExercise3.1-6onpage50inCLRS.
Exercise1-3.DoExercise3.2-4onpage57inCLRS.
Exercise1-4.DoProblem4.3-4onpage75ofCLRS.2Handout5:ProblemSet1
(a)
(b)
(c)
(d)and(notethelittle-)
(e)and
Problem1-2.Recurrences
Giveasymptoticupperandlowerboundsforineachofthefollowingrecurrences.Assumethatisconstantfor.Makeyourboundsastightaspossible,andjustifyyouranswers.
(a)
(b)
(c)
(d)Handout5:ProblemSet13
Figure1:Anexampleofaconvexpolygonrepresentedbythearray.isthevertexwiththeminimum-coordinate,andareorderedcounterclockwise.
(b)Giveanalgorithmtofindthevertexwiththemaximumcoordinateintime.
(c)Giveanalgorithmtofindthevertexwiththemaximumcoordinateintime.
麻省理工学院-算法导论
1 麻省理工学院-算法导论
关于课本的介绍如下:
本书自第一版出版以来,已经成为世界范围内广泛使用的大学教材和专业人员的标准参考手册。本书全面论述了算法的内容,从一定深度上涵盖了算法的诸多方面,同时其讲授和分析方法又兼顾了各个层次读者的接受能力。各章内容自成体系,可作为独立单元学习。所有算法都用英文和伪码描述,使具备初步编程经验的人也可读懂。全书讲解通俗易懂,且不失深度和数学上的严谨性。第二版增加了新的章节,如算法作用、概率分析与随机算法、线性编程等,几乎对第一版的各个部分都作了大量修订。
学过计算机的都知道,这本书是全世界最权威的算法课程的大学课本了,基本上全世界的名牌大学用的教材都是它。这本书一共四位作者,Thomas H. Cormen,Charles E. Leiserson和Ronald L. Rivest是来自MIT的教授,Clifford Stein是MIT出来的博士,现在哥伦比亚大学做教授,四人姓氏的首字母联在一起即是此书的英文简称(CLRS 2e),其中的第三作者Ronald
L. Rivest是RSA算法的老大(算法名字里面的R即是指他),四个超级大牛出的一本书,此书不看人生不能算完整。
再介绍一下课堂录像里面授课的两位MIT的老师,第一位,外表“绝顶聪明”的,是本书的第二作者Charles E. Leiserson,以逻辑严密,风趣幽默享誉MIT。第二位,留着金黄色的络腮胡子和马尾发的酷哥是Erik Demaine,21岁即取得MIT教授资格的天才,1981出生,今年才25岁,业余爱好是俄罗斯方块、演戏、琉璃、折纸、杂耍、魔术和结绳游戏。
另外,附上该书的中文电子版,pdg转pdf格式,中文版翻译自该书的第一版,中文书名没有使用《算法导论》,而使用的是《现代计算机常用数据结构和算法》,1994年出版时没有得到国外的授权,属于“私自翻译出版”,译者是南京大学计算机系的潘金贵。
《麻省理工学院-算法导论》(MIT - Introduction to Algorithms)概要
《麻省理工学院-算法导论》(MIT - Introduction to Algorithms)
这是麻省理工学院2001年秋季课程《算法导论》的所有课程资料,包括有:课本(含有习题,chm格式),课堂讲稿(ppt转pdf格式),作业及其答案(pdf格式),测验及其答案(pdf格式),教师参考(含习题答案,很难得,pdf格式),课堂录像(rmvb格式)。
关于课本的介绍如下:
本书自第一版出版以来,已经成为世界范围内广泛使用的大学教材和专业人员的标准参考手册。本书全面论述了算法的内容,从一定深度上涵盖了算法的诸多方面,同时其讲授和分析方法又兼顾了各个层次读者的接受能力。各章内容自成体系,可作为独立单元学习。所有算法都用英文和伪码描述,使具备初步编程经验的人也可读懂。全书讲解通俗易懂,且不失深度和数学上的严谨性。第二版增加了新的章节,如算法作用、概率分析与随机算法、线性编程等,几乎对第一版的各个部分都作了大量修订。
学过计算机的都知道,这本书是全世界最权威的算法课程的大学课本了,基本上全世界的名牌大学用的教材都是它。这本书一共四位作者,Thomas H. Cormen,Charles E. Leiserson和Ronald L. Rivest是来自MIT的教授,Clifford Stein是MIT出来的博士,现在哥伦比亚大学做教授,四人姓氏的首字母联在一起即是此书的英文简称(CLRS 2e),其中的第三作者Ronald
L. Rivest是RSA算法的老大(算法名字里面的R即是指他),四个超级大牛出的一本书,此书不看人生不能算完整。
再介绍一下课堂录像里面授课的两位MIT的老师,第一位,外表“绝顶聪明”的,是本书的第二作者Charles E. Leiserson,以逻辑严密,风趣幽默享誉MIT。第二位,留着金黄色的络腮胡子和马尾发的酷哥是Erik Demaine,21岁即取得MIT教授资格的天才,1981出生,今年才25岁,业余爱好是俄罗斯方块、演戏、琉璃、折纸、杂耍、魔术和结绳游戏。
MIT open courses
在中国,多数老师有时还是单方面的传声筒,学生是被排除在外的。
名校公开课,今天你淘了吗
不用点名,不用占座,没有考试,没有学分,想上就上的国外名校课程让中国的高校学生、白领阶层趋之若鹜,大声宣称——以前爱逃课,现在爱“淘”课!
你知道2006年哈佛大学最受欢迎的讲师是谁,去年最火爆的新生公共课又是哪门吗?你知道耶鲁大学那个半仙一样盘腿坐在讲台上大谈死亡哲学的大胡子老头吗?你知道即便不能坐在鼎鼎大名的常青藤院校课堂里,在家照样能够免费聆听大师的授课、理化工商文哲医史任君选择吗?
2001年,美国麻省理工学院率先拉开了网络公开课程的序幕,计划将该学院的全部课程资料都在网上公布,让全世界任何一个角落里的任一网络使用者都可以免费取用。嗅觉敏锐的人惊呼:高高在上的象牙塔正在卸下门锁、拆掉围墙,这是教学史上继远程函授之后又一令人激动的创举!
果然,麻省理工不是一个人在战斗。耶鲁、哈佛、剑桥、牛津等世界名校以及财力丰厚的基金会的陆续加入,犹如水滴汇成浪花,将“公开教育资源”(Open Educational Resources,O.E.R)运动推向了正轨,并且一发不可收。
不用点名,不用占座,没有考试,没有学分,想上就上的国外名校课程让中国的高校学生、白领阶层趋之若鹜,大声宣称——以前爱逃课,现在爱“淘”课!
大家都来OER
2005年以来,全球已经有150万人次在YouTube上浏览过戴蒙德教授的网络课程“综合生物”。除了她以外,还有许多世界顶级学校的大师 ——比如耶鲁大学经济学教授、当代行为金融学主要创始人罗伯特·希勒、哈佛大学“积极心理学——幸福课”的讲授者泰勒·本沙-哈尔、耶鲁大学的哲学“大仙”雪莱·卡根等,都成了走出校园、走向世界的网络新一代学术明星。
麻省理工学院72岁的物理学教授瓦尔特·勒温同样因为网络开放课程成为千万学子顶礼膜拜的对象。这位身高188厘米,满头白发的教授,为了介绍钟摆的周期与吊挂物体的质量无关,曾躺在从天花板垂下的吊索上,让自己像钟摆一样摆荡。“各位请看,这可是钟摆之母。”接着他在讲台上荡来荡去,然后喊道:“物理学果然不假!”教室立时爆出欢呼声,这段画面也通过网络传遍全世界
