- 1、本文档共39页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
Camp;ndash;CYao.ppt
C. –C. Yao Step Count of Fibonacci Program Two cases: n = 0 or n = 1 Line 4 regarded as two lines: 4(a) and 4(b), total step count in this case is 2 n 1 Line 4(a), 6, and 13 are each executed once Line 7 gets executed n times. Lines 8 – 12 get executed n-1 times each. Line 6 has s/e of 2 and the remaining lines have an s/e of 1. Total steps for the case n 1 is 4n + 1 C. –C. Yao Asymptotic Notation Determining step counts help us to compare the time complexities of two programs and to predict the growth in run time as the instance characteristics change. But determining exact step counts could be very difficult. Since the notion of a step count is itself inexact, it may be worth the effort to compute the exact step counts. Definition [Big “oh”]: f(n) = O(g(n)) iff there exist positive constants c and n0 such that f(n) ≤ cg(n) for all n, n ≥ n0 C. –C. Yao Examples of Asymptotic Notation 3n + 2 = O(n) 3n + 2 ≤ 4n for all n ≥ 3 100n + 6 = O(n) 100n + 6 ≤ 101n for all n ≥ 10 10n2 + 4n + 2 = O(n2) 10n2 + 4n + 2 ≤ 11n2 for all n ≥ 5 C. –C. Yao Asymptotic Notation (Cont.) Theorem 1.2: If f(n) = amnm + … + a1n + a0, then f(n) = O(nm). Proof: for n ≥ 1 So, f(n) = O(nm) C. –C. Yao Asymptotic Notation (Cont.) Definition: [Omega] f(n) = Ω(g(n)) iff there exist positive constants c and n0 such that f(n) ≥ cg(n) for all n, n ≥ n0. Example: 3n + 2 = Ω(n) 100n + 6 = Ω(n) 10n2 + 4n + 2 =Ω(n2) C. –C. Yao Asymptotic Notation (Cont.) Definition: f(n) = Θ(g(n)) iff there exist positive constants c1, c2, and n0 such that c1g(n) ≤ f(n) ≤ c2g(n) for all n, n ≥ n0. C. –C. Yao Asymptotic Notation (Cont.) Theorem 1.3: If f(n) = amnm + … + a1n + a0 and am 0, then f(n) = Ω(nm). Theorem 1.4: If f(n) = amnm + … + a1n + a0 and am 0, then f(n) = Θ(nm). C. –C. Yao Practical Complexities If a program P has complexities Θ(n) and program Q has complexities Θ(n2), then, in general, we can assume program P is faster than Q for a sufficient large n.
您可能关注的文档
- 青春期发育.ppt
- 项目12:自动变速器使用 及故障诊断.ppt
- 餐饮管理.ppt
- 骨髓细胞学检查.ppt
- 高级会计学_69949.ppt
- 高级操作员考证辅导.ppt
- 高级时事英语 English in Current Affairs.ppt
- ——2014年市二模试卷题型分析及单项选择、完形填空复习策.ppt
- 公输,名盘,也作般”或班”又称鲁班,山东人,是我.ppt
- 10zjfppt.ppt
- 第18讲 第17课 西晋的短暂统一和北方各族的内迁.docx
- 第15讲 第14课 沟通中外文明的“丝绸之路”.docx
- 第13课时 中东 欧洲西部.doc
- 第17讲 第16 课三国鼎立.docx
- 第17讲 第16课 三国鼎立 带解析.docx
- 2024_2025年新教材高中历史课时检测9近代西方的法律与教化含解析新人教版选择性必修1.doc
- 2024_2025学年高二数学下学期期末备考试卷文含解析.docx
- 山西版2024高考政治一轮复习第二单元生产劳动与经营第5课时企业与劳动者教案.docx
- 第16讲 第15课 两汉的科技和文化 带解析.docx
- 第13课 宋元时期的科技与中外交通.docx
文档评论(0)