Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

require the usage of recurrence as well as good class design Problem 2: Path Finding Problem Using C++ A robot is positioned on an integral

require the usage of recurrence as well as good class designimage text in transcribed

Problem 2: Path Finding Problem Using C++ A robot is positioned on an integral point in a two-dimensional coordinate grid (x,, y). There is a treasure that has been placed at a point in the same grid at (xt, yt). All x's and y's are integers. The robot can move up (North), down (South), left (West), or right (East). Commands can be given to the robot to move one position in one of the four direction. That is, "E" moves a robot one slot East (to the right) so if the robot was on position (3, 4), it would now be on (4, 4). The command N would move the robot one position north so a robot at position (4, 4) would be at (4, 5) Because the robot cannot move diagonally, the shortest distance between a robot at (xr, yr) and a treasure at (xt, Vt) is xr-Xt r -yt ShortestPossibleDistance Write a recursive program which determines all the unique shortest possible paths from the robot to the treasure The input to the program will be the starting position of the robot (xr, y) and the position of the treasure (xt, Vt). These will be in read from cin as four integers. For instance, an input of 1 3 -2 4 corresponds to the robot starting at position (1, 3) and needing to get to position (-2, 4). Do not worry about error conditions on input as we will assume the input is well formed. Read the input from cin The output of the program should be the listing of all the unique shortest possible paths followed by the number of unique paths. A path should be output as a string of characters with each character corresponding to a direction the Robot should move. For instance, NNENE corresponds to having the robot move North, North, East, North and East. This would be one answer to the input: 3 3 5 6, which corresponds to (3,3) -> (5,6) For the sake of efficiency, do not make two separate recursive calls in your program (one to count and one to print). Make sure that one recursive call handles both For the input 1 2 3 5 which corresponds to (1,2) -> (3,5) the output should be NNENE NNEEN NENNE NENEN NEENN ENNNE ENNEN ENENN Number of paths: 10

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

MySQL/PHP Database Applications

Authors: Brad Bulger, Jay Greenspan, David Wall

2nd Edition

0764549634, 9780764549632

More Books

Students also viewed these Databases questions

Question

8-2 What is the business value of security and control?

Answered: 1 week ago

Question

1. Which is the most abundant gas presented in the atmosphere?

Answered: 1 week ago

Question

Calculate the lifetime value (LTV) of a loyal customer.

Answered: 1 week ago