ImageVerifierCode 换一换
格式:PPT , 页数:43 ,大小:240KB ,
资源ID:378674      下载积分:2000 积分
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝扫码支付 微信扫码支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【http://www.mydoc123.com/d-378674.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(Asymptotic Growth Rate.ppt)为本站会员(吴艺期)主动上传,麦多课文库仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知麦多课文库(发送邮件至master@mydoc123.com或直接QQ联系客服),我们立即给予删除!

Asymptotic Growth Rate.ppt

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

19、a positive integer N such that 0 c * g (n ) f ( n) for all n N ,Cutler/Head,Growth of Functions 17,Is 5n-20 W (n)?,Proof: From the definition of Omega, there must exist c0 and integer N0 such that 0 cn 5n-20 for all nNDividing the inequality by n0 we get: 0 c 5-20/n for all nN.20/n 20, and 20/n beco

20、mes smaller as n grows.There are many choices here for c and N.Since c 0, 5 20/n 0 and N 4 For example, if we choose c=4, then 5 20/n 4 and N 20In this case we have a co and N0 such that 0 cn 5n-20 for all n N. So the definition is satisfied and 5n-20 W (n),Cutler/Head,Growth of Functions 18,W ( g (

21、 n ) = f (n) | there exist positive constant c and a positive integer N such that 0 c * g (n ) f ( n) for all n N ,1,000,000 n2 W (n2) why /why not?(n - 1)n / 2 W (n2) why /why not? n / 2 W (n2) why /why not?lg (n2) W ( lg n ) why /why not? n2 W (n) why /why not?,Cutler/Head,Growth of Functions 19,A

22、symptotic Tight Bound: Q,f (n),d g (n),f (n) = Q ( g ( n ),N,c g (n),Cutler/Head,Growth of Functions 20,Asymptotic Bound Theta: Q,Definition: Let f (n) and g(n) be asymptotically non-negative functions. We say f (n) is Q( g ( n ) if there are positive constants c, d and a positive integer N such tha

23、t for every n N 0 c g (n ) f ( n) d g ( n ).Or using more mathematical notation Q ( g ( n ) = f (n) | there exist positive constants c, d and a positive integer N such that 0 c g (n ) f ( n) d g ( n ). for all n N ,Cutler/Head,Growth of Functions 21,More on Q,We will use this definition: Q (g (n) =

24、O( g (n) ) W ( g (n) ),Cutler/Head,Growth of Functions 22,We show:,Cutler/Head,Growth of Functions 23,Cutler/Head,Growth of Functions 24,Cutler/Head,Growth of Functions 25,More Q,1,000,000 n2 Q(n2) why /why not? (n - 1)n / 2 Q(n2) why /why not? n / 2 Q(n2) why /why not? lg (n2) Q ( lg n ) why /why n

25、ot? n2 Q(n) why /why not?,Cutler/Head,Growth of Functions 26,Limits can be used to determine Order,c then f (n) = Q ( g (n) if c 0 if lim f (n) / g (n) = 0 or c 0 then f (n) = o ( g(n) or c 0 then f (n) = W ( g (n)The limit must exist,n,Cutler/Head,Growth of Functions 27,Example using limits,Cutler/

26、Head,Growth of Functions 28,LHopitals Rule,If f(x) and g(x) are both differentiable with derivatives f(x) and g(x), respectively, and if,Cutler/Head,Growth of Functions 29,Example using limits,Cutler/Head,Growth of Functions 30,Example using limits,Cutler/Head,Growth of Functions 31,Example using li

27、mits,n,O,e,e,e,n,kn,k,k,n,k,k,n,n,n,n,n,n,n,k,n,n,k,n,n,k,n,n,n,k,=,=,=,=,=,=,-,=,=,=,-,-,),(,ln,lim,lim,ln,lim,(,),ln,.,.,.,lim,!,ln,ln,ln,ln,2,2,2,2,2,2,2,1,2,2,2,2,0,2,2,2,1,2,2,where k is,a positiv,e integer.,(,),=,ln2,Cutler/Head,Growth of Functions 32,Another upper bound “little oh”: o,Definit

28、ion: Let f (n) and g(n) be asymptotically non-negative functions We say f ( n ) is o ( g ( n ) if for every positive real constant c there exists a positive integer N such that for all n N 0 f(n) 0, there exists a positive integer N 0 such that 0 f( n) c g (n ) for all n N “little omega” can also be

29、 defined,Cutler/Head,Growth of Functions 33,main difference between O and o,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 o ( g (n) ) = f(n) | for any positive constant c 0, there exists a positive integer N such that 0 f( n) c

30、g (n ) for all n N For o the inequality holds for all positive constants.Whereas for O the inequality holds for some positive constants.,Cutler/Head,Growth of Functions 34,Lower-order terms and constants,Lower order terms of a function do not matter since lower-order terms are dominated by the highe

31、r order term.Constants (multiplied by highest order term) do not matter, since they do not affect the asymptotic growth rateAll logarithms with base b 1 belong to (lg n) since,Cutler/Head,Growth of Functions 35,Asymptotic notation in equations,What does n2 + 2n + 99 = n2 + Q(n) mean?n2 + 2n + 99 = n

32、2 + f(n) Where the function f(n) is from the set Q(n). In fact f(n) = 2n + 99 .Using notation in this manner can help to eliminate non-affecting details and clutter in an equation. ? 2n2 + 5n + 21= 2n2 + Q (n ) = Q (n2),Cutler/Head,Growth of Functions 36,Transitivity:,If f (n) = Q (g(n ) and g (n) =

33、 Q (h(n ) then f (n) = Q (h(n ) .If f (n) = O (g(n ) and g (n) = O (h(n ) then f (n) = O (h(n ). If f (n) = W (g(n ) and g (n) = W (h(n ) then f (n) = W (h(n ) .If f (n) = o (g(n ) and g (n) = o (h(n ) then f (n) = o (h(n ) .If f (n) = w (g(n ) and g (n) = w (h(n ) then f (n) = w (h(n ),Cutler/Head,

34、Growth of Functions 37,Reflexivity:,f (n) = Q (f (n ).f (n) = O (f (n ). f (n) = W (f (n ).“o” is not reflexive,Cutler/Head,Growth of Functions 38,Symmetry and Transpose symmetry:,Symmetry: f (n) = Q ( g(n ) if and only if g (n) = Q (f (n ) . Transpose symmetry: f (n) = O (g(n ) if and only if g (n)

35、 = W (f (n ). f (n) = o (g(n ) if and only if g (n) = w (f (n ).,Cutler/Head,Growth of Functions 39,Analogy between asymptotic comparison of functions and comparison of real numbers.,f (n) = O( g(n) a b f (n) = W ( g(n) a b f (n) = Q ( g(n) a = b f (n) = o ( g(n) a b,Cutler/Head,Growth of Functions

36、40,Not All Functions are Comparable,The following functions are not asymptotically comparable:,Cutler/Head,Growth of Functions 41,Cutler/Head,Growth of Functions 42,Is O(g(n) = (g(n) o(g(n)?,We show a counter example: The functions are: g(n) = n and f(n)O(n) but f(n) (n) and f(n) o(n),Conclusion: O(

37、g(n) (g(n) o(g(n),Cutler/Head,Growth of Functions 43,General Rules,We say a function f (n ) is polynomially bounded if f (n ) = O ( nk ) for some positive constant k We say a function f (n ) is polylogarithmic bounded if f (n ) = O ( lgk n) for some positive constant kExponential functions grow faster than positive polynomial functions grow faster than polylogarithmic functions,

copyright@ 2008-2019 麦多课文库(www.mydoc123.com)网站版权所有
备案/许可证编号:苏ICP备17064731号-1