




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
GrowthofFunctions(函数增加)2/10/10CollegeofComputerScience&Technology,BUPTTheGrowthofFunctionsWequantifytheconceptthatg
growsatleastasfastasf.Whatreallymattersincomparingthecomplexityofalgorithms?Weonlycareaboutthebehaviorforlarge
problems.Evenbadalgorithmscanbeusedtosolvesmallproblems.Ignoreimplementationdetailssuchasloopcounterincrementation,etc.Wecanstraight-lineanyloop.3/10/10CollegeofComputerScience&Technology,BUPTOrdersofGrowth(§3.2)Forfunctionsovernumbers,weoftenneedtoknowaroughmeasureofhowfastafunctiongrows.Iff(x)isfastergrowingthang(x),thenf(x)alwayseventuallybecomeslargerthang(x)inthelimit(forlargeenoughvaluesofx).Usefulinengineeringforshowingthatonedesignscalesbetterorworsethananother.4/10/10CollegeofComputerScience&Technology,BUPTOrdersofGrowth-MotivationSupposeyouaredesigningawebsitetoprocessuserdata(e.g.,financialrecords).SupposedatabaseprogramAtakesfA(n)=30n+8microsecondstoprocessanynrecords,whileprogramBtakesfB(n)=n2+1microsecondstoprocessthenrecords.Whichprogramdoyouchoose,knowingyou’llwanttosupportmillionsofusers?A5/10/10CollegeofComputerScience&Technology,BUPTVisualizingOrdersofGrowthOnagraph,as
yougotothe
right,thefaster-
growingfunc-
tionalways
eventually
becomesthe
largerone...fA(n)=30n+8IncreasingnfB(n)=n2+1Valueoffunction6/10/10CollegeofComputerScience&Technology,BUPTConceptoforderofgrowthWesayfA(n)=30n+8
is(atmost)
ordern,orO(n).Itis,atmost,roughlyproportionalton.fB(n)=n2+1isordern2,orO(n2).Itis(atmost)roughlyproportionalton2.Anyfunctionwhoseexact(tightest)
orderisO(n2)isfaster-growingthananyO(n)function.LaterwewillintroduceΘforexpressingexactorder.Forlargenumbersofuserrecords,theexactlyordern2functionwillalwaystakemoretime.7/10/10CollegeofComputerScience&Technology,BUPTTheBig-ONotationDefinition:LetfandgbefunctionsfromNorRtoR.Theng
asymptoticallydominates(渐进地支配)f,denotedfisO(g)or'fisbig-Oofg,iff$k$c"n[n>k®|f(n)|£c|g(n)|]“fisatmostorderg”,or“fisO(g)”,or“f=O(g)”alljustmeanthatfO(g).Note:ChoosekChoosec;itmaydependonyourchoiceofkOnceyouchoosekandc,youmustprovethetruthoftheimplication(oftenbyinduction)8/10/10CollegeofComputerScience&Technology,BUPTPointsaboutthedefinitionNotethatfisO(g)solongasanyvaluesofcandkexistthatsatisfythedefinition.But:Theparticularc,k,valuesthatmakethestatementtruearenotunique:Anylargervalueofcand/orkwillalsowork.
Youarenotrequiredtofindthesmallestcandkvaluesthatwork.(Indeed,insomecases,theremaybenosmallestvalues!)However,youshouldprovethatthevaluesyouchoosedowork.9/10/10CollegeofComputerScience&Technology,BUPTlittle-oofgIncalculusIfThenfiso(g)(calledlittle-oofg)10/10/10CollegeofComputerScience&Technology,BUPTTheoremIffiso(g)thenfisO(g).Proof:bydefinitionoflimitasngoestoinfinity,f(n)/g(n)getsarbitrarilysmall.Thatisforanye>0,theremustbeanintegerNsuchthatwhenn>N,|f(n)/g(n)|<e.Hence,choosec=e
andk=N.Q.E.D.11/10/10CollegeofComputerScience&Technology,BUPTExample3n+5isO(n2)Proof:It'seasytoshowusingthetheoryoflimits.Hence3n+5iso(n2)andsoitisO(n2).Q.E.D.12/10/10CollegeofComputerScience&Technology,BUPTExample13/10/10CollegeofComputerScience&Technology,BUPT“Big-O”ProofExamplesShowthat30n+8isO(n).Showc,k:n>k:
30n+8cn.Letc=31,k=8.Assumen>k=8.Then
cn=31n=30n+n>30n+8,so30n+8<cn.Showthatn2+1isO(n2).Showc,k:n>k:n2+1cn2.Letc=2,k=1.Assumen>1.Then
cn2=2n2=n2+n2>n2+1,orn2+1<cn2.14/10/10CollegeofComputerScience&Technology,BUPTNote30n+8isn’t
lessthann
anywhere(n>0).Itisn’teven
lessthan31n
everywhere.Butitislessthan
31n
everywhereto
therightofn=8.n>k=8Big-Oexample,graphicallyIncreasingnValueoffunctionn30n+8cn=
31n30n+8
O(n)15/10/10CollegeofComputerScience&Technology,BUPTSomeimportantBig-OresultsTheorem1Letf(x)=anxn
+
an-1xn-1
+…+a1x+a0
,wherea0,
a1,
…an-1,an
arerealnumbers.Thenf(x)isO(xn).n!isO(nn)logn!isO(nlogn)lognisO(n)1,logn,n,nlogn,n2,2n,n!16/10/10CollegeofComputerScience&Technology,BUPTThegrowthofcombinationsoffunctionsTheorem2Supposethatf1isO(g1)andf2isO(g2).Thenf1+f2isO(max{g1,g2})Corollary1Iff1,f2arebothO(g)thenf1+f2isO(g).Theorem3Supposethatf1isO(g1)andf2isO(g2).Thenf1f2isO(g1g2)17/10/10CollegeofComputerScience&Technology,BUPTProofoff1f2isO(g1g2)Thereisak1andc1suchthat1.f1(n)<c1g1(n)whenn>k1.Thereisak2andc2suchthat2.f2(n)<c2g2(n)whenn>k2.Wemustfindak3andc3suchthat3.f1(n)f2(n)<c3g1(n)g2(n)whenn>k3.18/10/10CollegeofComputerScience&Technology,BUPTProofoff1f2isO(g1g2)Weusetheinequalityif0<a<band0<c<dthenac<bdtoconcludethatf1(n)f2(n)<c1c2g1(n)g2(n)aslongask>max{k1,k2}sothatbothinequalities1and2.holdatthesametime.Therefore,choosec3=c1c2andk3=max{k1,k2}.Q.E.D.19/10/10CollegeofComputerScience&Technology,BUPTExampleFindthecomplexityclassofthefunction(nn!+3n+2
+3n100)(nn
+n2n
)Solution:Thismeanstosimplifytheexpression.Throwoutstuffwhichyouknowdoesn'tgrowasfast.Andatlast:nn!nn20/10/10CollegeofComputerScience&Technology,BUPTBig-omeganotationDefinition:LetfandgbefunctionsfromNorRtoR.Wesayfis(g)or'fisbig-ofg,'iff$k$c"n[n>k®|f(n)|c|g(n)|]Note:ChoosekChoosec;itmaydependonyourchoiceofkOnceyouchoosekandc,youmustprovethetruthoftheimplication(oftenbyinduction)21/10/10CollegeofComputerScience&Technology,BUPTBig-thetanotationIffO(g)andgO(f),thenwesay“gandfareofthesameorder”or“fis(exactly)orderg”andwritef(g).Another,equivalentdefinition:
(g){f:RR|
c1c2k>0x>k:|c1g(x)||f(x)||c2g(x)|}“Everywherebeyondsomepo
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025至2030中国环境美化及园艺服务行业产业运行态势及投资规划深度研究报告
- 服务贸易统计培训课件
- 学生学习风格与个性化教学策略
- 教师职业发展与教学质量的提升策略研究
- 退换货培训课件
- 教育数字化转型中的技术革新与挑战
- 智慧城市公共服务平台的数据管理与分析
- 钢结构焊接培训课件
- 教育大数据在教学管理中的创新应用
- 抖音商户短视频播放量分析反馈制度
- 2025年广州市事业单位教师招聘考试生物学科专业知识试题
- 幼儿小小运动会活动方案
- C语言程序设计说课课件
- 2023年对外汉语教育学引论知识点
- 对立违抗障碍行为矫正
- 高一下学期期末考模拟卷(第一、二册综合)(基础)- 《温故知新》2025-2026学年高一数学下学期复习课(人教A版2029必修第二册)(原卷版)
- 《文旅服务信息资源分类及编码规范》
- 2025年四川成都环境投资集团有限公司及下属公司招聘笔试参考题库含答案解析
- 2025年行政法与行政诉讼考试试题及答案
- 工伤免责赔协议书
- 考研机构入学协议书
评论
0/150
提交评论