DIRECTIONS for the following questions:
These questions are based on the situation given below: A robot moves on a graph sheet with x and y-axes. 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 (x, y), x > 0 and 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:
WALKX(-x) and WALKY(y) are the commands to be used for the robot to reach origin in any order.
Hence, the answer is 2.
Create a FREE account and get: