The task is to show that given algorithm has STOP property and to find its computational complexity function.
$\alpha:$ $n \ge 0$
void fun(int n) {
a=0;b=n+1;
while ((a + 1) != b) {
p = (a + b)/2;
if (p ∗ p > n)
b = p;
else a = p;
}
}
I have already proven its partial correctness as it was also part of the task, however I do have problem with these things that I have mentioned above.
I think it can be easily seen that it is gonna stop as 'a' is getting bigger and bigger, but I don't really know how to notate or show it in more mathematical way.
Thanks for your help.
(a + 1)! = bsupposed to be(a + 1) != bor do you really mean the factorial $(a + 1)!$ of $a + 1$? $\endgroup$