如何在改变输入大小时找到时间复杂性?

时间:2017-01-19 23:39:50

标签: algorithm time-complexity asymptotic-complexity

我想知道在doubling输入大小时如何计算函数的时间复杂度。我特别指的是着名的Algorithms Design练习题。

Example Problem Questions Here

解决方案: Solutions

首先,看起来他只是将值插入到函数中。 n^3变为(2n)^3,因此变为8n^3,因此8 times slower

我开始感到困惑的地方是nlogn2^n。我是否缺少某种技巧来执行此计算,还是只是数学替换?我已经阅读了他书中的章节,似乎无法找到解决方案。

1 个答案:

答案 0 :(得分:0)

只需使用简单的身份:

2nlog(2n) = 2n(logn + log2) = 2nlogn + 2nlog2 

2^(2n) = (2^n)^2

似乎很明显哪些答案适合。