I'm reading the book Introduction to Algorithms, Third Edition. In an exercise, we are asked to use inductive reasoning to prove
T(n) = {2 if n = 2, 2T(n/2) + n if n > 2^k for k > 1} = nlgn
Where lg is log base 2. The book provides the solution:
Base Case:
n = 2, T(2) = 2, 2lg(2) = 2
Assumption:
T (n/2) = (n/2)lg(n/2)
Induction:
T (n) = 2T (n/2) + n
= 2(n/2)lg(n/2) + n
= n(lg n − 1) + n
= n lg n − n + n
= n lg n
Could someone explain why the value n/2 is used in the Assumption step? With my understanding of induction, I would have used the value 2^n
and then later incremented it to 2^(n+1)
in order to cover all possible powers of 2. I want to know why I'm wrong. Furthermore, could someone explain the operations that change 2(n/2)lg(n/2)+n into n(lg n-1) + n?
It doesn't adhere to the mathematical conventions that I'm aware of.