北京邮电大学 计算机学院 离散数学 3.23.3-Growth of Functions.ppt

北京邮电大学 计算机学院 离散数学 3.23.3-Growth of Functions.ppt

  1. 1、本文档共53页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
北京邮电大学计算机学院离散数学3.2

* * College of Computer Science Technology, BUPT Example 1: Max algorithm Problem: Find the simplest form of the exact order of growth (?) of the worst-case time complexity (w.c.t.c.) of the max algorithm, assuming that each line of code takes some constant time every time it is executed (with possibly different times for different lines of code). * * College of Computer Science Technology, BUPT Complexity analysis of max procedure max(a1, a2, …, an: integers) v := a1 t1 for i := 2 to n t2 if ai v then v := ai t3 return v t4 First, what’s an expression for the exact total worst-case time? (Not its order of growth.) Times for each execution of each line. * * College of Computer Science Technology, BUPT Complexity analysis, cont. procedure max(a1, a2, …, an: integers) v := a1 t1 for i := 2 to n t2 if ai v then v := ai t3 return v t4 w.c.t.c.: Times for each execution of each line. * * College of Computer Science Technology, BUPT Complexity analysis, cont. Now, what is the simplest form of the exact (?) order of growth of t(n)? * * College of Computer Science Technology, BUPT Example 2: Linear Search procedure linear search (x: integer, a1, a2, …, an: distinct integers) i := 1 t1 while (i ? n ? x ? ai) t2 i := i + 1 t3 if i ? n then location := i t4 else location := 0 t5 return location t6 * * College of Computer Science Technology, BUPT Linear search analysis Worst case time complexity order: Best case: Average case, if item is present: * * College of Computer Science Technology, BUPT Review §3.3: Complexity Algorithmic complexity = cost of computation. Focus on time complexity for our course. Although space energy are also important. Characterize complexity as a function of input size: Worst-case, best-case, or average-case. Use orders-of-growth notation to concisely summarize the growth properties of complexity functions. * * College of Computer Scie

文档评论(0)

xcs88858 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

版权声明书
用户编号:8130065136000003

1亿VIP精品文档

相关文档