Proving that $\lfloor{i/2^h}\rfloor = \lfloor \lfloor\cdots \lfloor i/2\rfloor/2\cdots\rfloor/2\rfloor$

47 Views Asked by At

I am trying to prove that $$\left\lfloor{\frac{i}{2^h}}\right\rfloor$$ equals to performing a series of $h$ operations of $$\left\lfloor\frac{\left\lfloor\frac{\left\lfloor\frac{i}{2}\right\rfloor}{2}\right\rfloor}{2}\right\rfloor $$ etc...

I am using this property as part of a larger proof for an algorithm and this property is all I need... any help?

1

There are 1 best solutions below

0
On

Hint: You can show that it is true if $i < 2^h$ easily. In both cases, the evaluation is $0$.

After that, you can prove it easily for $2^h$. Both are equal to $1$ as in the second case each time we have a power of $2$ and the result is integer each time.

For the last case $i > 2^h$. Hence, we can write it likes $i = 2^n + k$ whcih $n \geq h$ and $k < 2^h$. First case is $2^{n-h}$. we can prove for the second case easily by induction over $n$ with base of $n = h$.