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
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
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question

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

Step 1
solution
Step by step
Solved in 2 steps

Knowledge Booster
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.Recommended textbooks for you

Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON

Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education