The code you submit should apply all three findPath functions to each map, one after the other. The map input files named map1.txt, map2.txt, and map3.txt can be downloaded from the canvas. Example of a map input file: 7 10 Start - OXXXXXXXXX 00000000XX OXOXOXOXXX OXOXOX0000 XXOXXXOXXX X0000000XX XXXXXXX000Z - Destination

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter17: Linked Lists
Section: Chapter Questions
Problem 10PE
icon
Related questions
Question
1. Using the above class map, write function void map::mapToGraph(graph &g){...} to create a graph g that represents the
legal moves in the map m. Each vertex should represent a cell, and each edge should represent a legal move between
adjacent cells.
2. Write a recursive function findPathRecursive(graph &g, stack<int> &moves) that looks for a path from the start island
to the destination island. If a path from the start to the destination exists, your function should call the map::printPath()
function that should print a sequence of correct moves (Go left, Go right, Go down, Go up, etc.). If no path from the
start to the destination exists, the program should print, "No path exists". If a solution exists the solver should also
simulate the solution to each map by calling the map::print() function. The map::print() function prints out a map
visualization, with the goal and current position of the car in the map at each move, marked to show the progress. Hint:
consider recursive-DFS.
3. Write a function findPathNon Recursive1(graph &g, stack<int> &moves) that does the same thing as in 2, but by using
stack and without using recursion. If a path from the start to the destination exists, your function should call the
map::printPath() function that should print a sequence of correct moves (Go left, Go right, Go down, Go up, etc.). If no
path from the start to the destination exists, the program should print, "No path exists". If a solution exists the solver
should also simulate the solution to each map by calling the map::print() function. The map::print() function prints out a
map visualization, with the goal and current position of the car in the map at each move, marked to show the progress.
Hint: consider stack-based DFS.
4. Write a function findPathNon Recursive2(graph &g, queue<int> &moves) that does the same thing as in 2, but by
using queue and without using recursion. If a path from the start to the destination exists, your function should call the
map::printPath() function that should print a sequence of correct moves (Go left, Go right, Go down, Go up, etc.). If no
path from the start to the destination exists, the program should print, "No path exists". If a solution exists the solver
should also simulate the solution to each map by calling the map::print() function. The map::print() function prints out a
map visualization, with the goal and current position of the car in the map at each move, marked to show the progress.
Hint: consider queue-based BFS.
The code you submit should apply all three findPath functions to each map, one after the other.
The map input files named map1.txt, map2.txt, and map3.txt can be downloaded from the canvas. Example of a map
input file:
7
10
Start - OXXXXXXXXX
00000000XX
OXOXOXOXXX
OXOXOX0000
XXOXXXOXXX
X0000000XX
XXXXXXX000Z - Destination
Transcribed Image Text:1. Using the above class map, write function void map::mapToGraph(graph &g){...} to create a graph g that represents the legal moves in the map m. Each vertex should represent a cell, and each edge should represent a legal move between adjacent cells. 2. Write a recursive function findPathRecursive(graph &g, stack<int> &moves) that looks for a path from the start island to the destination island. If a path from the start to the destination exists, your function should call the map::printPath() function that should print a sequence of correct moves (Go left, Go right, Go down, Go up, etc.). If no path from the start to the destination exists, the program should print, "No path exists". If a solution exists the solver should also simulate the solution to each map by calling the map::print() function. The map::print() function prints out a map visualization, with the goal and current position of the car in the map at each move, marked to show the progress. Hint: consider recursive-DFS. 3. Write a function findPathNon Recursive1(graph &g, stack<int> &moves) that does the same thing as in 2, but by using stack and without using recursion. If a path from the start to the destination exists, your function should call the map::printPath() function that should print a sequence of correct moves (Go left, Go right, Go down, Go up, etc.). If no path from the start to the destination exists, the program should print, "No path exists". If a solution exists the solver should also simulate the solution to each map by calling the map::print() function. The map::print() function prints out a map visualization, with the goal and current position of the car in the map at each move, marked to show the progress. Hint: consider stack-based DFS. 4. Write a function findPathNon Recursive2(graph &g, queue<int> &moves) that does the same thing as in 2, but by using queue and without using recursion. If a path from the start to the destination exists, your function should call the map::printPath() function that should print a sequence of correct moves (Go left, Go right, Go down, Go up, etc.). If no path from the start to the destination exists, the program should print, "No path exists". If a solution exists the solver should also simulate the solution to each map by calling the map::print() function. The map::print() function prints out a map visualization, with the goal and current position of the car in the map at each move, marked to show the progress. Hint: consider queue-based BFS. The code you submit should apply all three findPath functions to each map, one after the other. The map input files named map1.txt, map2.txt, and map3.txt can be downloaded from the canvas. Example of a map input file: 7 10 Start - OXXXXXXXXX 00000000XX OXOXOXOXXX OXOXOX0000 XXOXXXOXXX X0000000XX XXXXXXX000Z - Destination
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Operations of Linked List
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning