I am looking to prove that T(n)=T(n/2)+sqrt(n) is O(sqrt(n)) given T(1)=1
using only induction.
It is easy to solve using the Master theorem but this is not the case.
I tried to assume
T(n/2) < c*sqrt(n/2)
but didnt get very far with the rest of the proof.
Thank you all in advance for your answers.
Edit:
my line of solution (after the assumption above) is:
T(n) <= c*sqrt(n/2)+sqrt(n) = sqrt(n)(c/sqrt(2)+1) <= sqrt(n)(c+1)
I dont know how to move from this to the required
T(n)<=c*sqrt(n)
ok, you’re close. So basically, as I mentioned in the comment, base case is simple. For induction case, you want to show that T(n) is O(sqrt(n)) given that T(n/2) is O(sqrt(n/2)).
So, it goes like this:
observe that for c > 4, c / sqrt(2) + 1 < c, so
so
Therefore, T(n) is O(sqrt(n))
So there’s a couple key points here that you missed.
The first is that you can always increase the c to whatever value you want. This is because big O only requires <. if it’s < c f(n) then it is < d f(n) where d > c.
The second is to note that the line f(c) = c/sqrt(2) + 1 intersects with the line f(c) = c at about c = sqrt(2) / (sqrt(2)-1) = 3.4143 (or so), so all you have to do is force c to be > this value in order to get (c/sqrt(2) + 1) < c. 4 certainly works, so that’s where the 4 comes from.
In retrospect, I should have given the key points as hints. My fault. Sorry!