# Does this problem have more than what it seems to me ?

• 07-16-2012
manasij7479
Does this problem have more than what it seems to me ?
Attachment 11820
It seems, to me that the program/function always terminates.
(Though it doesn't produce the intended result (the function is named 'mu' which I guess, is for multiplication) for a < 0).
And the 'Q' required is just the Loop Invariant (right?), which I think is "y=i*b".

Or am I missing something large, considering that this is for a post grad paper and I've just begun my college education(two weeks, to be exact).

(The whole question paper is here)
• 07-16-2012
stevesmithx
I have a hunch that condition P is about finding/avoiding boundary conditions to get an infinite loop, but that is most likely wrong.
If the loop invariant were say
Quote:

i <= a
Quote:

i < a
, then we have an infinite loop at
Quote:

mu(INT_MAX,x)
.
For the given case though, I couldn't find any.
• 07-16-2012
phantomotap
O_o

Yeah, I'm not getting it either; the instructions are crazy vague.

Code:

`if (0 = 0) do exit`
Does that insanity actually fit both roles?

Soma
• 07-16-2012
Salem
Q should be some expression involving a,b,i,y (those things involved in the loop)
• 07-17-2012
phantomotap
Quote:

Q should be some expression involving a,b,i,y (those things involved in the loop)
Bwahahaa!

Okay, so, just to confirm here, this isn't about writing code at all is it? It is about reasoning through existing code isn't it?

Soma
• 07-17-2012
manasij7479
I think so.
Something conceptually similar to assert.
Thats why I think Q will be "y==i*b".
But I have no idea what P can be.

(W.r.t the first comment, shouldn't language/implementation based things like INT_MAX, be left out of consideration in algorithms? )