Asymptotic Growth Rate.ppt
《Asymptotic Growth Rate.ppt》由会员分享,可在线阅读,更多相关《Asymptotic Growth Rate.ppt(43页珍藏版)》请在麦多课文档分享上搜索。
1、Cutler/Head,Growth of Functions 1,Asymptotic Growth Rate,CS575 / Class 1,Growth of Functions 2,Function Growth,The running time of an algorithm as input size approaches infinity is called the asymptotic running time We study different notations for asymptotic efficiency. In particular, we study tigh
2、t bounds, upper bounds and lower bounds.,Cutler/Head,Growth of Functions 3,Outline,Why do we need the different sets? Definition of the sets O, Omega and Theta Classifying examples: Using the original definition Using limits General Properties Little Oh Additional properties,Cutler/Head,Growth of Fu
3、nctions 4,The “sets” and their use big Oh,Big “oh” - asymptotic upper bound on the growth of an algorithm When do we use Big Oh? Theory of NP-completeness To provide information on the maximum number of operations that an algorithm performs Insertion sort is O(n2) in the worst case This means that i
4、n the worst case it performs at most cn2 operations Insertion sort is also O(n6) in the worst case since it also performs at most dn6 operations,Cutler/Head,Growth of Functions 5,The “sets” and their use Omega,Omega - asymptotic lower bound on the growth of an algorithm or a problem* When do we use
5、Omega? 1. To provide information on the minimum number of operations that an algorithm performs Insertion sort is (n) in the best case This means that in the best case its instruction count is at least cn, It is (n2) in the worst case This means that in the worst case its instruction count is at lea
6、st cn2,Cutler/Head,Growth of Functions 6,The “sets” and their use Omega cont.,2. To provide information on a class of algorithms that solve a problem Sort algorithms based on comparison of keys are (nlgn) in the worst case This means that all sort algorithms based only on comparison of keys have to
7、do at least cnlgn operations Any algorithm based only on comparison of keys to find the maximum of n elements is (n) in every case This means that all algorithms based only on comparison of keys to find maximum have to do at least cn operations,Cutler/Head,Growth of Functions 7,The “sets” and their
8、use - Theta,Theta - asymptotic tight bound on the growth rate of an algorithm Insertion sort is (n2) in the worst and average cases The means that in the worst case and average cases insertion sort performs cn2 operations Binary search is (lg n) in the worst and average cases The means that in the w
9、orst case and average cases binary search performs clgn operations Note: We want to classify an algorithm using Theta. In Data Structures used Oh Little “oh” - used to denote an upper bound that is not asymptotically tight. n is in o(n3). n is not in o(n),CS575 / Class 1,Growth of Functions 8,The fu
10、nctions,Let f(n) and g(n) be asymptotically nonnegative functions whose domains are the set of natural numbers N=0,1,2,. A function g(n) is asymptotically nonnegative, if g(n)0 for all nn0 where n0N,Cutler/Head,Growth of Functions 9,Asymptotic Upper Bound: big O,f (n),c g (n),f (n) = O ( g ( n ),N,W
11、hy only for n N ? What is the purpose of multiplying by c 0?,Graph shows that for all n N, f(n) c*g(n),Cutler/Head,Growth of Functions 10,Asymptotic Upper Bound: O,Definition: Let f (n) and g(n) be asymptotically non-negative functions. We say f (n) is in O ( g ( n ) if there is a real positive cons
12、tant c and a positive Integer N such that for every n N 0 f (n) c g (n ).Or using more mathematical notation O ( g (n) ) = f (n )| there exist positive constant c and a positive integer N such that 0 f( n) c g (n ) for all n N ,Cutler/Head,Growth of Functions 11,n2 + 10 n O(n2) Why?,0,200,400,600,80
13、0,1000,1200,1400,0,10,20,30,n2 + 10n,2 n2,take c = 2 N = 10 2n2 n2 + 10 n for all n=10,Cutler/Head,Growth of Functions 12,Does 5n+2 O(n)?,Proof: From the definition of Big Oh, there must exist c0 and integer N0 such that 0 5n+2cn for all nN. Dividing both sides of the inequality by n0 we get:0 5+2/n
14、c. 2/n 2, 2/n0 becomes smaller when n increases There are many choices here for c and N. If we choose N=1 then c 5+2/1= 7. If we choose c=6, then 0 5+2/n6. So N 2. In either case (we only need one!) we have a co and N0 such that 0 5n+2cn for all n N. So the definition is satisfied and 5n+2 O(n),Cutl
15、er/Head,Growth of Functions 13,Does n2 O(n)? No.,We will prove by contradiction that the definition cannot be satisfied. Assume that n2 O(n). From the definition of Big Oh, there must exist c0 and integer N0 such that 0 n2cn for all nN. Dividing the inequality by n0 we get 0 n c for all nN. n c cann
16、ot be true for any n maxc,N , contradicting our assumption So there is no constant c0 such that nc is satisfied for all nN, and n2 O(n),Cutler/Head,Growth of Functions 14,O ( g (n) ) = f (n )| there exist positive constant c and positive integer N such that 0 f( n) c g (n ) for all n N ,1,000,000 n2
17、 O(n2) why/why not? (n - 1)n / 2 O(n2) why /why not? n / 2 O(n2) why /why not? lg (n2) O( lg n ) why /why not?n2 O(n) why /why not?,Cutler/Head,Growth of Functions 15,Asymptotic Lower Bound, Omega: W,f (n),c * g (n),f(n) = ( g ( n ),N,Cutler/Head,Growth of Functions 16,Asymptotic Lower Bound: W,Defi
18、nition: Let f (n) and g(n) be asymptotically non-negative functions. We say f (n) is W ( g ( n ) if there is a positive real constant c and a positive integer N such that for every n N 0 c * g (n ) f ( n). Or using more mathematical notation W ( g ( n ) = f (n) | there exist positive constant c and
- 1.请仔细阅读文档,确保文档完整性,对于不预览、不比对内容而直接下载带来的问题本站不予受理。
- 2.下载的文档,不会出现我们的网址水印。
- 3、该文档所得收入(下载+内容+预览)归上传者、原创作者;如果您是本文档原作者,请点此认领!既往收益都归您。
下载文档到电脑,查找使用更方便
2000 积分 0人已下载
下载 | 加入VIP,交流精品资源 |
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- ASYMPTOTICGROWTHRATEPPT
