edited by
538 views
0 votes
0 votes

Answer the question based on the following information.
A robot moves on a graph sheet with X and Y-axis. The robot is moved by feeding it with a sequence of instructions. The different instructions that can be used in moving it, and their meanings are:

Instruction Meaning
GOTO(x,y) Move to point with coordinates (x, y) no matter where you are currently
WALKX(p) Move parallel to the X-axis through a distance of p, in the positive direction if p is positive, and in the negative direction if p is negative.
WALKY(p) Move parallel to the Y-axis through a distance of p, in the positive direction if p is positive, and in the negative direction if p is negative.

The robot is initially at $\text{ (x, y), x} > 0$ and $\text{y} < 0$. The minimum number of instructions needed to be executed to bring it to the origin $(0, 0)$ if you are prohibited from using the GOTO instruction is

  1. $2$
  2. $1$
  3. $\text{x+y}$
  4. $0$
edited by

1 Answer

4 votes
4 votes

Robot can reach to initial point (0,0) . in two instructions  . 
 

WALKX(-X) ---> now robot will reach to  (0,y) where y<0
now WALKY(Y) ----> now robot will reach to (0,0) 

So only 2 insructions are required . 

option (A) is correct .

 

Related questions