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. java计算今天是今年的第几天

    Calendar.getInstance().get(Calendar.DAY_OF_YEAR)

  2. DirectUI消息循环的简单封装

      一.真窗体和假窗体 首先在DirectWindow内部创建一个真窗体(基于WTL),可以接收消息 class CMessageWindow : public CWindowImpl< CMe ...

  3. perl debug

    1. 进入debug模式 # perl -d ./perl_debugger.pl it prompts, DB<1>   2. 查看从第10行开始的代码. 查看函数get_pattern ...

  4. mysql5.7报err 1055错误 sql_mode=only_full_group_by

    vim /etc/my.cnf 末尾增加 sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_B ...

  5. Android关于log日志,华为不输出log.v,log.d(zz)

    [java] view plain copy 我用的是mate8,本来虚拟机测试一点日志一点问题没有 [java] view plain copy 但是真机测试发现log.d一直不输出,正好又试了lo ...

  6. 深入理解JVM(一)——JVM内存模型

    JVM内存模型 Java虚拟机(Java Virtual Machine=JVM)的内存空间分为五个部分,分别是: 1. 程序计数器 2. Java虚拟机栈 3. 本地方法栈 4. 堆 5. 方法区. ...

  7. 疯狂Java学习笔记(75)-----------NIO.2第一篇

    Java 7引入了NIO.2.NIO.2是继承自NIO框架,并添加了新的功能(比如:处理软链接和硬链接的功能).这篇帖子包含三个部分,我将使用NIO.2的一些演示样例.由此向大家演示NIO.2的基本用 ...

  8. 解决nginx access日志中400 bad request 错误(转)

    在access.log中有大量400错误,并以每天几百M的速度增加,占用大量空间.tail -f /opt/nginx/logs/access.log 116.236.228.180 - - [15/ ...

  9. 部分Linux时区改为东八区的方法

    直接上命令 CentOS: timedatectl set-timezone Asia/Shanghai timedatectl status date Alphine: apk add tzdata ...

  10. 基于Centos搭建Laravel 环境搭建

    系统要求:CentOS 7.2 64 位操作系统 安装 Laravel Laravel 简介 Laravel 是一套简洁.优雅的 PHP Web 开发框架.它可以让你从面条一样杂乱的代码中解脱出来:它 ...