Given $\log(n + 1)-1\le h\le\log n$. How does $h$ turn out to be $\lfloor \log n \rfloor$?

46 Views Asked by At

I was reading through an algorithms book for my CS class, and came across this inequality: $\log(n + 1)-1\le h\le\log n$.

The author concludes with this result: $h = \lfloor \log n \rfloor$

I tried using a property of the floor function from Rosen's book: $ \lfloor x \rfloor = m \iff x-1 \lt m \le x $ and tried considering $ \log n $ as my $x $, but I couldn't reach his result because of the $ +1 $ in my first logarithm.

How did he end up with $h = \lfloor \log n \rfloor$ ?

1

There are 1 best solutions below

0
On BEST ANSWER

You know there is only one integer $h$ with $\log n-1<h\le \log n$ (namely $\lfloor{\log n}\rfloor$). But clearly $\log (n+1)-1>\log n-1$ so if there is an integer in $[\log (n+1)-1,\log n]$ it has to be $\lfloor{\log n}\rfloor$.