Reputation: 210
How would you guys go along with solving a recurrence relation with the substitution method, that has the square root in it? Like
T(n) = T(\sqrt{n}) + n
Upvotes: 0
Views: 191
Reputation: 59174
This is how I actually solved it:
First, there is obviously a lower bound in Ω(n)
Also, I notice that it expands to n + n1/2 + n1/4... The sizes decrease more quickly than n + n/2 + n/4..., and I know that has an upper bound in O(n), So T(n) must be in O(n), too.
Since T(n) is in Ω(n) and in O(n), then it's also in Θ(n).
So now it's solved -- we know the answer. If this is a test question, though, then you'd have to write a proof of that upper bound, which you could accomplish a number of different ways.
I would do it by induction. Given a constant A and some n such that:
T(n) < An
Then we have:
T(n2) = T(n) + n2 < An + n2 = (A/n+1)n2
And if A and n are sufficiently large, then (A/n + 1) < A, so
T(n2) < An2
Upvotes: 1