Reading algorithms by self using Robert Sedwick book in C++
A recursive function that divides a problem of size N into two
independent (nonempty) parts that it solves recursively calls itself
less than N times.If the parts are one of size k and one of size N-k, then the total
number of recursive calls that we use is T(n) = T(k) + T(n-k) + 1, for
N>=1 with T(1) = 0.The solution T(N) = N-1 is immediate by induction. If the sizes sum to
a value less than N, the proof that the number of calls is less than
N-1 follows from same inductive argument.
My questions on above text are
- How author came with solution T(N) = N-1 by induction? Please help me to understand.
- What does author mean by “If the sizes sum to a value less than N, the proof that the number of calls is less than N-1 follows from same inductive argument” ?
I am new to mathematical induction so having difficulty in understanding.
Thanks for your time and help
(1) By induction:
We assume for each
n < N, we getT(n) = n-1Since both
kandN-kare smaller thenN, we get from the induction hypothesis:(2)
Using the same argument:
if
Then the same proof will lead to
T(N) < N-1