博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
基础复习-算法设计基础 | 复杂度计算
阅读量:5962 次
发布时间:2019-06-19

本文共 1685 字,大约阅读时间需要 5 分钟。

一. 算法时间复杂度比较符号

 

Definition of Asymptotic Signature

  一般讨论的 “计算算法的(时间)复杂度” 是人们为了衡量算法性能创造的一种评估方法,我们引入O,Ω,Θ符号来表示算法的复杂度比较关系,在实际分析中我们默认:f,g are monotonic functions and maps from positive to positive.

 

"O" signature:

    • We say f(n) = O(g(n)) if g(n) eventually domains f(n).

  Or:

    • If there exists a constant c such thta for all sufficient large n: f(n) ≤ c*g(n). 

"Ω" signature:

    • We say f(n) = Ω(g(n)) if f(n) eventually domains g(n).

  Or:

    • If there exists a constant c such that for all sufficient large n: f(n) ≥ c*g(n).

"Θ" signature:

  -We say f(n) = Θ(g(n)) if f(n) = O(g(n))   and f(n) = Ω(g(n))

Note here in the definition of big o and big sigma, the constant c locate at the same position at the formular, but we can understand it like this:

  • f(n) ≥ c*g(n)
  • 1/c*f(n) ≥ g(n)
  • a*f(n) ≥ g(n)

so we can think we are searching for a big constant c(a) to magnitude the domianing function in both asymptotic relation.

 

Approach of Sorting Functions in Asymptotic Order

Basically we can classify functions into three types: logarithmic, polinomial, exponencial function.

This is because functions belong to these three types are strictly in ascending asymptotic order:

证明对数函数增长慢于多项式函数:

    • 令f(n) = n, 则 f(n) = O(P(n))
    • 现证log(n) = O(f(n)):

令Φ(n) = c*f(n) - log(n)

令Φ'(n) = c - 1/n = 0, 得c = 1/n

故Φ(n)在 n = 1/c处取最小值为Φ(1/c) = 1 + log(c)

得到:当1 + log(c)>0 时,c*f(n) > log(n) 恒成立

证明指数函数增长快于多项式函数:

The properties of logarithic function:

    1. 和差
    2. 换底
    3. 指系
    4. 还原
    5. 互换
    6. 倒数
    7. 链式

Practice:

sorting functions below in ascending asymptotic order:

  1. log(nn), n2, nlog(n), nlog(log(n)), 2log(n), log2(n), n2^1/2
  2. n2.5, (2n)1/2, n+10, 10n, 100n, n2logn
  3. 2(logn)1/2, 2n, n4/3, nlogn, 22^n, 2n^2

 

 

 

 

 

 

转载于:https://www.cnblogs.com/qinziang/p/9241521.html

你可能感兴趣的文章
Android开发之Canvas rotate方法释疑
查看>>
Cors 跨域Access-Control-Allow-Origin
查看>>
[React] React Router: Router, Route, and Link
查看>>
USACO holstein AC code
查看>>
linux下限制ip访问
查看>>
Winform文件下载之WebClient
查看>>
linux添加环境变量
查看>>
Dumpsys Input Diagnostics
查看>>
ASP.NET MVC 入门8、ModelState与数据验证
查看>>
被swoole坑哭的PHP程序员
查看>>
linux进程调度之 FIFO 和 RR 调度策略---SYSTEMTAP
查看>>
JSTL的相关使用
查看>>
ActiveMQ, RabbitMQ和ZeroMQ 选型关注点
查看>>
王垠:完全用Linux工作
查看>>
Understanding the Router
查看>>
红米3 Flyme5.1.9.5插桩适配长期不定时更新
查看>>
MySQL 5.6 for Windows 解压缩版配置安装(转)
查看>>
组件居中显示 安卓
查看>>
delete
查看>>
sql server生成不重复的时间字符串
查看>>