Question

Prove that the following algorithm has STOP property. I am not sure if this term is widely know, so the definition of STOP property that I got during classes looks as follows:

STOP property (for all input data satisfying $ \alpha $ the computation halts - the number of steps is finite)

$\alpha: x \in N $

void BB(int x)
{
    int y = x;
    int z = 0;
    while((z != 0) || (y <= 300))
    {
        if(y <= 300)
        {
            y = y + 3;
            z = z + 1;
        }
        else
        {
            y = y - 2;
            z = z - 1;
        }
    }
}

I do not really have any idea how to approach such a problem. I was thinking about using the method of loop counters, but I couldn't success with it.

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with cs.stackexchange
scroll top