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. org.apache.ibatis.binding.BindingException: Type interface XXX is not known to the MapperRegistry.

    动态代理因为namespace的地方写错了

  2. C语——宏小结

    c语言关于宏的使用十分频繁.但是宏的使用有利也有弊,与此同时,它还是一个特别容易搞错的地方.正是基于此,它常常成为一些面试会侧重考察的地方. 所谓宏就是 #define 机制包括的一个规定,即允许把参 ...

  3. Detour3.0 win7 64bit下的安装

    最近在做API hook相关的东西,用了inline hook后感觉不错,但是查找资料发现inline hook并不稳定 inline hook 的原理是在系统访问一个函数的时候先替换原函数入口处的内 ...

  4. android:应用性能优化SparseArray

    HashMap是java里比较常用的一个集合类,我比较习惯用来缓存一些处理后的结果.最近在做一个Android项目,在代码中定义这样一个变量,实例化时,Eclipse却给出了一个 performanc ...

  5. 【Spark】Spark性能调优

    官网:http://spark.apache.org/docs/latest/tuning.html 1.引言 提到Spark与Hadoop的区别,基本最常说的就是Spark采用基于内存的计算方式,尽 ...

  6. C# Chart使用总结 2 ----属性

    默认显示如图所示,Series的名称显示在右边,它会将下方空间挤掉,使图表只能显示在左侧,而右侧大部分地方都是空白的.当图很宽的时候看着会很不舒服.   可以设置Legends 集合中的Docking ...

  7. MySQL SELECT 执行的具体步骤

    1:SELECT 执行的顺序 8SELECT 9DISTINCT <select_list> 1FROM <left_table> 3JOIN <right_table& ...

  8. VTK拾取网格模型上的可见点

    消隐与Z-Buffer 使用缓冲器记录物体表面在屏幕上投影所覆盖范围内的全部像素的深度值,依次访问屏幕范围内物体表面所覆盖的每一像素,用深度小(深度用z值表示,z值小表示离视点近)的像素点颜色替代深度 ...

  9. Ext4 ReiserFS Btrfs 等7种文件系统性能比拼

    2009年02月04日     为了满足广大群众的热切需求,今天做了 Ext2.Ext3.Ext4.XFS.JFS.ReiserFS 和 Btrfs 的全面性能测试,对比结果如下:     本次测试所 ...

  10. NeoFinder for Mac(增强型文件管理工具)破解版安装

    1.软件简介    NeoFinder 是 macOS 系统上一款帮助用户管理磁盘的 Mac 工具,NeoFinder for mac 能迅速组织您的数据,无论是在外部或内部磁盘,或任何其他卷.它能记 ...