We’re rewarding the question askers & reputations are being recalculated! Read more.

New answers tagged

3

Figure out what the value of y is, depending on x, a, and c. Prove that your formula is correct before the first iteration, and prove that if it is true before an iteration then it is also true after the iteration.


2

It is $O(\log^2 \frac{\text{dividend}}{\text{divisor}})$. The inner loop clearly takes at most $O(\log \frac{\text{dividend}}{\text{divisor}})$ time since initially $k= \text{divisor}$ and it is doubled at every iteration. The outer loop requires at most $O(\log \frac{\text{dividend}}{\text{divisor}})$ iterations since the inner loop subtracts from $\text{...


Top 50 recent answers are included