Asymptotic Algorithm Analysis

Part 1:Definitions

T(n): The running time as a function on the input size n.

S(n): The used space as a function on the input size n.

Big-Oh(upper bound): ForT(n) a non-negatively valued function,T(n) is in the setO(f(n)), if there exist two positive constants c and n0such that T(n)≤cf(n) for alln>n0.

EX: If T(n)=3n2 then T(n) is in O(n2), and also in O(n3).


Big-Omega(lower bound): For T(n) a non-negatively valued function,T(n) isin the set Omega(g(n))if there exist two positive constants andn0 such that T(n)≥cg(n) for alln> n0.

EX: T(n)=c1n2+c2n c1n2 for all n >1. Therefore T(n)=Omega(n2) by the definition for c=c1 and n0=1.


Theta Notation: For T(n) a non-negatively valued funvtion, T(n)=Theta(h(n)) if T(n)=O(h(n)) and T(n)=Omega(h(n)).



Part 2: Simplifying Rules

Once you determine the running-time or used-space equation for an algorithm, you do not need to resort the formal definition of asmptotic analysis. Instead, you can use the following rules to determine the simplest form.


1. If f(n) is in O(g(n)), and g(n) is in O(h(n)), then f(n) is in O(h(n)).

2. If f(n)=O(g(n)) for any constant k > 0, then f(n)=O(g(n)).

3. If f 1 ( n )= O( g 1 ( n )) and f 2 ( n )= O( g 2 ( n )), then f 1 ( n )+ f 2 ( n )= O(max( g 1 ( n ), g 2 ( n ))).  e.g:3n2+2n + 4 = O(3n2)= O(n2).
4. If f 1 ( n )= O( g 1 ( n )) and f 2 ( n )= O( g 2 ( n )) then f 1 ( n ) f 2 ( n )= O( g 1 ( n ) g 2 ( n )).

NOTICE: These rules also hold true for Omega and Theta.







  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值