f(n) 的形式 vs 判定形势

但,此题型过于简单,一般不出现在考题中。

Extended:

link

Let's set n = 2^m, so m = log(n)

T(n) = 2*T(n^(1/2)) + 1 =>

T(2^m) = 2*T(2^(m/2)) + 1 =>

S(M) = 2*S(M/2)) + 1

通过变量替换,变为了熟悉的、主定理能解决的 形式 => S(m) ~ O(m)

故,S(m) = T(log(n)) ~ O(log(n))

link

关键点:match 主定理(3)的条件。

a*f(n/b) <= c*f(n)  ->

3*f(n/4) <= c*f(n)  ->

3*(n/4)*log(n/4) <= c*n*log(n)  ->

3/4 * n*log(n/4) <= c*n*log(n)

可见,有c<1时,是满足的。

答案就是O(nlogn)

When f(x) = x*sqrt(x+1)

这里的常数1是个tricky.

去掉它,x^(3/2)

变为x,sqrt(2)*[x^(3/2)]

可见,f(x)~Θ(x^(3/2))

T(n)=T(⌊n/2⌋)+T(⌊n/4⌋)+T(⌊n/8⌋)+n.

link

n+(7/8)*n+(7/8)^2 *n+(7/8)^3 *n+⋯ 等比数列!

so we have a geometric series and thus,

for our upper bound.

In a similar way, we could count just the contribution of the leftmost branches and conclude that T(n)≥2n.

Putting these together gives us the desired bound, T(n)=Θ(n)

Extended:

Recurrence Relation T(n)=T(n/8)+T(n/4)+lg(n)

太难:Solution.

(a) T(n) = T(n-1) + cn         link

(b) T(n) = T(n-1) + log(n)    link

(c) T(n) = T(n-1) + n^2      link

(d) T(n) = T(n-1) + 1/n       link

(a) 递归展开,探寻规律:

T(n)=T(n−3)+(n−2)c+(n−1)c+nc

At the end we use T(2)=T(1)+2c=1+2cT(2)=T(1)+2c=1+2c. We conclude that

T(n)=1+(2+3+⋯+n)c.

可见是O(n^2)

(b) 递归展开,探寻规律:

T(n) = T(n - 1) + log n

= T(n - 2) + log (n - 1) + log n

= T(n - 3) + log (n - 2) + log (n - 1) + log n

= ...

= T(0) + log 1 + log 2 + ... + log (n - 1) + log n

= T(0) + log n!

According to Stirling's formula, 可见是O(n*log(n))

(c) 递归展开,探寻规律:

T(n)=T(0)+1^2+2^2+3^2+⋯+n^2

Or simply,

O(n^3)

(d) 这里是个调和级数

This is the nth harmonic number, Hn = 1 + 1/2 + 1/3 + ... + 1/n.

"所有调和级数都是发散于无穷的。但是其拉马努金和存在,且为欧拉常数。"

In fact, Hn = ln(n) + γ + O(1/n)

Hint:比较难,需换两次元。

[Algorithm] Asymptotic Growth Rate的更多相关文章

  1. 本人AI知识体系导航 - AI menu

    Relevant Readable Links Name Interesting topic Comment Edwin Chen 非参贝叶斯   徐亦达老板 Dirichlet Process 学习 ...

  2. The Go Programming Language. Notes.

    Contents Tutorial Hello, World Command-Line Arguments Finding Duplicate Lines A Web Server Loose End ...

  3. Exercises for IN1900

    Exercises for IN1900October 14, 2019PrefaceThis document contains a number of programming exercises ...

  4. Caching Best Practices--reference

    reference:http://java.dzone.com/articles/caching-best-practices There is an irresistible attraction ...

  5. WPF依赖对象(DependencyObject) 实现源码,理解WPF原理必读

    /// DependencyObject encompasses all property engine services. It's primary function /// is providin ...

  6. Background removal with deep learning

    [原文链接] Background removal with deep learning   This post describes our work and research on the gree ...

  7. (转)Awesome PyTorch List

    Awesome-Pytorch-list 2018-08-10 09:25:16 This blog is copied from: https://github.com/Epsilon-Lee/Aw ...

  8. Ethereum White Paper

    https://github.com/ethereum/wiki/wiki/White-Paper White Paper EditNew Page James Ray edited this pag ...

  9. CSUOJ 2031 Barareh on Fire

    Description The Barareh village is on fire due to the attack of the virtual enemy. Several places ar ...

随机推荐

  1. 初识CocosCreator的一些问题

    本文的cocos creator版本为v1.9.0,除此外大部分都是以v1.9.3版本 1.color赋值 cc.Label组件并没有颜色相关的属性,但是Node有color的属性. //如果4个参数 ...

  2. MySql md5加密 sqlserver md5加密 C# md5加密 java md5加密

    便民md5加密: 百度md5加密: MySQL 加密语法: MD5(加密字符串) -- 中文加密 SELECT MD5('你好') -- 中文加密匹配查询 SELECT * FROM 表名 WHERE ...

  3. Linux学习笔记15—RPM包的安装OR源码包的安装

    RPM安装命令1. 安装一个rpm包rpm –ivh 包名“-i” : 安装的意思“-v” : 可视化“-h” : 显示安装进度另外在安装一个rpm包时常用的附带参数有:--force : 强制安装, ...

  4. SVN clean失败解决方法【转】

    原文地址:http://blog.csdn.net/victory08/article/details/42100325/ svn执行clean up后出现提示:svn cleanup failed– ...

  5. VS2010环境下Winpcap配置方法 (转)

    VS2010 配置Winpcap 新建一个项目,GetDevs.cpp.用来测试.测试代码最后有给出. View->Property Manager Debug|Win32 -> Mirc ...

  6. Tkinter(2.x 与3.X的区别)

    1.包的引入 2.X下是 from Tkinter import * 而3.x是 from tkinter import * 否则,会报找不到tkinter的错误 Traceback (most re ...

  7. 《Attention is All You Need》

    https://www.jianshu.com/p/25fc600de9fb 谷歌最近的一篇BERT取得了卓越的效果,为了研究BERT的论文,我先找出了<Attention is All You ...

  8. Java线程池 / Executor / Callable / Future

    为什么需要线程池?   每次都要new一个thread,开销大,性能差:不能统一管理:功能少(没有定时执行.中断等).   使用线程池的好处是,可重用,可管理.   Executor     4种线程 ...

  9. Shell脚本高级编程笔记一

     http://www.cnblogs.com/ygj0930/p/8184277.html 一:函数 1:创建函数 法一: function name{ commands } 法二: name() ...

  10. 安装babel遇到的异常

    Error: Requires Babel "^7.0.0-0", but was loaded with "6.26.3". If you are sure ...