1
$\begingroup$

The given problem is from CLRS, exercise 4.3-2.

Show that the solution of T(n)=T(⌈n/2⌉)+1=O(log(n))

I decided to prove T(n) ≤ clog(n) and this is the result I got:

T(n)≤clog(n/2)+1
= clog(n)-clog(2)+1
= clog(n)-c+1
≤ clog(n)

From my understanding of how the substitution method and induction works is that, clog(n)-c+1 has to be smaller or equal to clog(n). Assuming n ≥ 1 and c ≥ 1, this seems to have worked from my tests. I then decided to look at solutions online, but noticed that all other solutions are proving it by adding lower order stuff. Some examples I saw where T(n) ≤ clog(n)-2, or 3log(n)-1 or clog(n)-a where a is some constant. Why would anyone want to make the problem more difficult when it can be solved without adding things to it. My question is does my solution work? If it doesn't, what is the reason for it? If possible please explain as simple as possible because I am not very good at math proofs, thank you very much!

$\endgroup$
1
  • $\begingroup$ The problem probably comes from the fact that you are dropping the ceiling. If you want to show by induction that $T(n) \le c \log n$ then the first step of your proof should be $T(n) \le c \log \lceil n/2 \rceil \le \log \frac{n+1}{2}$. In practice the ceiling won't make any difference a far as the asymptotic growth rate is concerned. There are formal arguments that allow you to drop ceilings from recurrences. Search for "domain transformation". $\endgroup$
    – Steven
    Sep 20, 2021 at 13:19

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.