We can write down a table and look for a pattern:
n T(n)
- ----
2 a
4 T(2) + a = 2a
16 T(4) + a = 3a
256 T(16) + a = 4a
...
2^(2^k) (k+1)a
We noticed 2 = 2^(2^0)
, 4 = 2^(2^1)
, 16 = 2^(2^2)
, and so on; by starting with two and squaring over and over, we get terms like 2^(2^k)
for which the corresponding values of T(n)
are simply (k+1)a
.
Given that n = 2^(2^k)
and T(n) = (k+1)a
, we can solve the first of these equations for k
in terms of n
and then substitute in the second. We get that log log n = k
and so T(n) = (1 + log log n)a
, which has the asymptotic bound you are after.
Technically, to complete this argument, we must note that T(n)
is a monotonically non-decreasing function and so it is sufficient that we have shown the function is bounded in this way for this particular sequence of values of n
. In general, a function might behave in such a way that the above method of analysis might be fooled into suggesting an inaccurate bound. For well-behaved functions this will not typically occur.