When you start unrolling the recursion, you get:
Here the same thing with a few additional steps:
Now using the boundary condition for a recursion (number 2 selected as 0 and 1 do not make sense), you will get:
Substituting k
back to the equation you will get:
Here are a couple of recursions that use the same idea.
- T(n) = T(n^1/2) + 1
- T(n) = T(n^1/2) + O(loglog(n))