Consider the following recurrence
T(n) = 3T(n/5) + lgn * lgn
What is the value of T(n)?
(A) Theta(n ^ log_5{3})
(B) Theta(n ^ log_3{5})
(c) Theta(n Log n )
(D) Theta( Log n )
Answer is (A)
My Approach :
lgn * lgn = theta(n) since c2lgn < 2*lglgn < c1*lgn for some n>n0
Above inequality is shown in this picture for c2 = 0.1 and c1 = 1
log_5{3} < 1,
Hence by master theorem answer has to be theta(n) and none of the answers match. How to solve this problem??
Your claim that lg n * lg n = Θ(n) is false. Notice that the limit of (lg n) 2 / n tends toward 0 as n goes to infinity. You can see this using l'Hopital's rule:
lim n → ∞ (lg n) 2 / n
= lim n → ∞ 2 lg n / n
= lim n → ∞ 2 / n
= 0
More generally, using similar reasoning, you can prove that lg n = o(n ε ) for any ε > 0.
Let's try to solve this recurrence using the master theorem. We see that there are three subproblems of size n / 5 each, so we should look at the value of log 5 3. Since (lg n) 2 = o(n log 5 3 ), we see that the recursion is bottom-heavy and can conclude that the recurrence solves to O(n log 5 3 ), which is answer (A) in your list up above.
Hope this helps!
To apply we should check the relation between 我们应该检查它们之间的关系
n log 5 (3) ~= n 0.682 and (lg(n)) 2
Unfortunately lg(n) 2 != 2*lg(n): it is lg(n 2 ) that's equal to 2*lg(n)
Also, there is a big difference, in Master Theorem, if f(n) is O(n log b (a)-ε ), or instead Θ(n log b a ): if the former holds we can apply case 1, if the latter holds case 2 of the theorem.
With just a glance, it looks highly unlikely (lg(n)) 2 = Ω(n 0.682 ), so let's try to prove that (lg(n)) 2 = O(n 0.682 ), ie:
∃ n 0 , c ∈ N + , such that for n>n 0 , (lg(n)) 2 < c * n 0.682
Let's take the square root of both sides (assuming n > 1, the inequality holds)
lg(n) < c 1 * n 0.341 , (where c 1 = sqrt(c))
now we can assume, that lg(n) = log 2 (n) (otherwise the multiplicative factor could be absorbed by our constant - as you know constant factors don't matter in asymptotic analysis) and exponentiate both sides:
2 lg(n) < 2 c 2 * n 0.341 <=> n < 2 c 2 * n 0.341 <=> n < (n 2 0.341 ) c 2 <=> n < (n 2 0.341 ) c 2 <=> n < (n 1.266 ) c 2
which is immediately true choosing c 2 = 1 and n 0 = 1
Therefore, it does hold true that f(n) = O(n log b (a)-ε ), and we can apply case 1 of the , and conclude that: 情况1,并得出结论:
T(n) = O(n log 5 3 )
Same result, a bit more formally.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.