Need hints/solution to solve for a in terms of n in the equation:
$$a = \sqrt{n} + \sqrt{a}$$
I'm actually trying to get and solve the recurrence for the following piece of code:
while (n > 1)
{
n = (long)Math.Sqrt(n);
// do something
}
I felt that for this piece of code:
$$T(n) = \sqrt{n} + \sqrt{T(n)}$$
and hence arrived at the equation above by writing T(n) = a.
n = (long)Math.Sqrt(n);
would be the recurrence $T(n+1) = \lfloor \sqrt{T(n)} \rfloor$ (but of course you don't show what comes after that line of code). I seriously suggest you run the code step by step for a few iterations, understand what it's doing, and figure out what your question really is before posting. – dxiv Oct 04 '16 at 03:08//do something
is independent of n. Hence omitted. My exact question is to understand the time complexity of the code above. Unfortunately such a question is not properly answered on SO. So, I came to MSE. – displayName Oct 04 '16 at 03:13C
notation, in which case the(long)
cast truncates (rounds down a la $\lfloor x \rfloor$). P.S. [displayName] The code you posted does not round up. – dxiv Oct 04 '16 at 03:25