How to get the upper bound of the following equation, thanks!
2log(mn/2) + 4log(mn/4) + ... + mlog(mn/m)
This sum works out to Θ(m log n).
Let's start by rewriting
2k log (mn / 2k) = 2k(log mn - k)
Now, we have the sum
Σk=1log m 2k (log mn - k)
= Σk=1log m (2k log mn - k 2k)
= log mn Σk=1log m 2k - Σk=1log m k 2k
That first sum is the sum of a geometric series. It simplifies to 21 + log m - 2 = 2m - 2. That means that we're left with
2m log mn - 2log mn - Σk=1log m k 2k
That leaves us with the task of simplifying the sum k2k over some range. This is an arithmetico-geometric sum. If we imagine this sum ranging from 2 (inclusive) to some upper bound q, then the sum works out to q2q+1.
(q+1)2q+1 - 2 + 2(2 - 2q+1)
= (q+1)2q+1 - 2 + 4 - 2·2q+1
= (q - 1)2q+1 + 2
You can check that this formula is correct by plugging in different values of q.
In our case, q = log m, so the sum we want works out to
(log m - 1)21 + log m + 2
= (log m - 1)(2m) + 2
= 2m log m - 2m + 2
So our overall sum works out to
2m log mn - 2log mn - Σk=1log mn k 2k
= 2m log mn - 2log mn - (2m log m - 2m + 2)
= 2m log mn - 2log mn - 2m log m + 2m - 2
= 2m (log mn - log m + 1) - 2log mn - 2
= 2m (log n + 1) - 2 log mn - 2
Θ(m log n).
Hope this helps!