[英]Solving recurrence of divide and conquer using master theorem
Can T(n) = 3T(n/2) + c T(1)=0, solved using master theorem? T(n) = 3T(n/2) + c T(1)=0 可以用主定理求解吗? If yes, I am struggling on understand master theorem now, could someone tell me which case it falls to and why.如果是的话,我现在正在努力理解主定理,有人能告诉我它属于哪种情况以及为什么。
There are different possible approaches for the master theorem.主定理有不同的可能方法。 I like the one proposed by Cormen et al.我喜欢 Cormen 等人提出的那个。 in their book Introduction to Algorithms .在他们的《算法导论》一书中。
Now we need to compare f(n) with n^(log b (a)) .现在我们需要比较f(n)和n^(log b (a)) 。
Note that the three cases do not cover all the possibilities for f(n).请注意,这三种情况并未涵盖 f(n) 的所有可能性。 There is a gap between cases 1 and 2 when f(n) is smaller than n^(log b (a)) but not polynomially smaller.当 f(n) 小于n^(log b (a))但不是多项式更小时,情况 1 和情况 2 之间存在差距。 Similarly, there is a gap between cases 2 and 3 when f(n) is larger than n^(log b (a)) but not polynomially larger.类似地,当 f(n) 大于n^(log b (a))但不是多项式更大时,情况 2 和情况 3 之间存在差距。 If the function f(n) falls into one of these gaps, or if the regularity condition in case 3 fails to hold, you cannot use the master method to solve the recurrence.如果 function f(n) 落入其中之一,或者情况 3 中的正则性条件不成立,则无法使用 master 方法求解递归。
Now to solve the recurrence in question...现在要解决有问题的复发......
a=3, b=2, f(n) = c = n^0 a=3, b=2, f(n) = c = n^0
so we have n^(log2(3)) ≈ n^(1.58) which is polynomially larger than n^0, falling under the 1st case.所以我们有 n^(log2(3)) ≈ n^(1.58) 多项式大于 n^0,属于第一种情况。 Then the time complexity is T(n) = Θ(n^(log b (a))) --> T(n) = Θ(n^1.58)那么时间复杂度就是T(n) = Θ(n^(log b (a))) --> T(n) = Θ(n^1.58)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.