edited by
522 views
5 votes
5 votes

Consider the following functions $f$ and $g$:

f(){
x = x+1;
x = y*y;
x = x-y;
}
g(){
y = y+1;
y = x*x;
y = y-x;
}

Suppose we start with initial values of $1$ for $x$ and $2$ for $y$ and then execute $f$ and $g$ in parallel-that is, at each step we either execute one statement from $f$ or one statement from $g.$ Which of the following is not a possible final state?

  1. $x = 2, y = 2$
  2. $x = 5, y = -1$
  3. $x = -63, y = 72$
  4. $x = 32, y = 5$
edited by

1 Answer

0 votes
0 votes
I think option 'D' is the correct answer.

Since we have to do either of the following operations

x=y*y or y=x*x

before

x=x-y or y=y-x

the sum of resultant numbers need to be a perfect square

A.x=2 y=2 ;x+y=4(perfect square)

B.x=5 y=-1 ;x+y=4(perfect square)

C.x=-63 y=72;x+y=9(perfect square)

D.x=32 y=5;x+y=37(not a perfect square)

Related questions

1 votes
1 votes
1 answer
1