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

  • 7
  • 0
  • 约7.38千字
  • 约 25页
  • 2017-11-26 发布于河南
  • 举报

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

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

College of Computer Science Technology, BUPT Discrete Mathematical Structures Yang Juan yangjuan@bupt.edu.cn College of Computer Science Technology Beijing University of Posts Telecommunications Growth of Functions(函数增长) * * College of Computer Science Technology, BUPT The Growth of Functions We quantify the concept that g grows at least as fast as f. What really matters in comparing the complexity of algorithms? We only care about the behavior for large problems. Even bad algorithms can be used to solve small problems. Ignore implementation details such as loop counter incrementation, etc. We can straight-line any loop. * * College of Computer Science Technology, BUPT Orders of Growth (§3.2) For functions over numbers, we often need to know a rough measure of how fast a function grows. If f(x) is faster growing than g(x), then f(x) always eventually becomes larger than g(x) in the limit (for large enough values of x). Useful in engineering for showing that one design scales better or worse than another. * * College of Computer Science Technology, BUPT Orders of Growth - Motivation Suppose you are designing a web site to process user data (e.g., financial records). Suppose database program A takes fA(n)=30n+8 microseconds to process any n records, while program B takes fB(n)=n2+1 microseconds to process the n records. Which program do you choose, knowing you’ll want to support millions of users? * * College of Computer Science Technology, BUPT Visualizing Orders of Growth On a graph, as you go to the right, the faster- growing func- tion always eventually becomes the larger one... fA(n)=30n+8 Increasing n ? fB(n)=n2+1 Value of function ? * * College of Computer Science Technology, BUPT Concept of order of growth We say fA(n)=30n+8 is (at most) order n, or O(n). It is, at most, roughly proportional to n. fB(n)=n2+1 is order n2, or O(n2). It is (at most) roughly proportional to n2. Any function whose exact (tightest) order is O(n2) is faster-growing than

文档评论(0)

1亿VIP精品文档

相关文档