solving a recurrence: T(n) = 4T(n/2) + n(logn)^2 - recursion

I'm trying to solve this recursive function but i reached a dead end:
T(n) = 4T(n/2) + n(logn)^2
I tried the master rule (with the 3 cases) and non of the cases applied. I also tried iteration method and got a complex equation...
Can anybody give me a final solution or a method how to solve it?
Thank you

Related

recursion equation for running time

I need to solve the recursion problem:
T(n) = T(n/2) + log^2(n)
when we call for n element we have log^2(n) actions (except the recursive actions) and so on until we call for 2 element and we have 1 action.
how do I calculate the T(n) running time?
this is SO, it's not the place to put a runtime question.
however, since it's already here, i'm gonna answer that, and probably get -5
the running time is O(log(n)). that's because calculating log^2(n) will take O(1), so that's insignificant for the run time. so we have
T(n) = T(n/2)
and that's a classic O(log(n))

What is the answer for: n! = Θ( )?

How do I find the answer for: n! = Θ( )?
Even Big O is enough. All clues I found are complex math ideas.
What would be the correct approach to tackle this problem? recursion tree seems too much of a work
the goal is to compare between n! and n^logn
Θ(n!) is a perfectly fine, valid complexity, so n! = Θ(n!).
As Niklas pointed out, this is actually true for every function, although, for something like
6x² + 15x + 2, you could write Θ(6x² + 15x + 2), but it would generally be preferred to simply write Θ(x²) instead.
If you want to compare two functions, simply plotting it on WolframAlpha might be considered sufficient to see that Θ(n!) functions grow faster.
To mathematically determine the result, we can take the log of both, giving us log (n!) and log nlog n = log n . log n = (log n)2.
Then, since log(n!) = Θ(n log n), and n log n > (log n)2 for any large n, we could derive that Θ(n!) grows faster.
The derivation is perhaps non-trivial, and I'm slightly unsure whether it's actually possible, but we're a bit beyond the scope of Stack Overflow already (try the Mathematics site if you want more details).
If you want some sort of "closed form" expressions, you can get n! = Ω((sqrt(n/2))^n) and n! = O(n^n). Note sure those are more useful.
To derive them, see that (n/2)^(n/2) < n! < n^n.
To compare against n^(log n), use limit rules; you may also want to use n = e^(log n).

Recursive Runtime of T(n-k)

I am trying to find the runtime of the equation;
T(n) = T(n-2) + n³.
When I am solving it I arrive at the summation T(n) = T(n-k) + Σk = 0,...,n/2(n-2k)³.
Solving that sum I get 1/8(n²)(n + 2)². Solving this I would get the runtime to be Θ(n⁴).
However, I think I did something wrong, does anyone have any ideas?
Why do you think that it is wrong? This equation is clearly Theta(n^4)
The more detailed solution can be obtained from WolframALpha (did you know it solves recurrence equations?)
https://www.wolframalpha.com/input/?i=T%28n%29%3DT%28n-2%29%2Bn%5E3
You can also add some border cases, like T(0)=T(1)=1
https://www.wolframalpha.com/input/?i=T%28n%29%3DT%28n-2%29%2Bn%5E3%2C+T%281%29%3D1%2C+T%282%29%3D1
and finally: asymptotic plot, showing that it truly behaves like n^4 function
Here is an attempt to show your recursive recursive recurrence with steps:
With WolframAlpha engine solving the summation.

How to calculate complexity from special Mergesort

i try to calculate the complexity from Mergesort.
Standard Mergesort has the recursion T(n) = T(n/2)+T(n/2)+n
So its easy to calculate with the Master-theorem.
But my question is, how to calculate a Mergesort with T(n) = T(2n/3) + T(n/3) + n
and T(n) = T(n-100) + T(100) ?
Can you help me guys?
Thanks =)
this two examples are the textbook examples of calculating the recursive equations .
for solving them you need to use "The Recursion Tree" method .
I know that the answer to the first condition is theta(nlogn) and the answer to the second one is theta(n^2) . now to find the solutions , I think you can get a pretty good perspective of The recursion tree in the Introduction to algorithms , CLRS .

Having issues dealing with T(n) runtime problems

I was going to meet with my TA today but just didn't have the time. I am in an algorithms analysis class and we started doing recurrence relations and I'm not 100% sure if I am doing this problem correct. I get to a point where I am just stuck and don't know what to do. Maybe I'm doing this wrong, who knows. The question doesn't care about upper or lower bounds, it just wants a theta.
The problem is this:
T(n) = T(n-1) + cn^(2)
This is what I have so far....
=T(n-2) + (n-1)^(2) + cn^(2)
=T(n-3) + (n-2)^(2) + 2cn^(2)
=T(n-4) + (n-3)^(2) + 3cn^(2)
So, at this point I was going to generalize and substitute K into the equation.
T(n-k) + (n-k+1)^(2) + c(K-1)^(2)
Now, I start to bring the base case of 1 into the picture. On a couple of previous, more simple problems, I was able to set my generalized k equation equal to 1 and then solve for K. Then put K back into the equation to get my ultimate answer.
But I am totally stuck on the (n-k+1)^(2) part. I mean, should I actually foil all this out? I did it and got k^(2)-2kn-2k+n^(2) +2n +1 = 1. At this point I'm thinking I totally must have done something wrong since I've never see this in previous problems.
Could anyone offer me some help with how to solve this one? I would greatly appreciate it.
What you have isn't fully correct even at the first line of "what I have so far".
Go ahead and do the full substitutions, to see that:
T(n-1) = T(n-2) + c(n-1)^2
so
T(n) = T(n-2) + c(n-1)^2 + c(n)^2
T(n) = T(n-3) + c(n-2)^2 + c(n-1)^2 + c(n)^2
Overall running time looks like adding "c(n-i)^2" for each value of i from 0 to your base case. Hopefully that puts you on the right track.

Resources