
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Concept explainers
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

arrow_forward
Step 1
solution
Step by stepSolved 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.Similar questions
- A for construct is a loop construct that processes a specified list of objects. As a result,it is executed as long as there are remaining objects to process. True or False?arrow_forwardPython Required information id fname lname company address city ST zip 103 Art Venere 8 W Cerritos Ave #54 Bridgeport NJ 8014 104 Lenna Paprocki Feltz Printing 639 Main St Anchorage AK 99501arrow_forwardAssessment Description Honors Students: Complete this assignment according to the directions provided in the "Honors Addendum," located in Class Resources. This activity has multiple parts. All parts must be completed prior to documentation submission. Part 1: Reading and Writing Text Files. In this activity, you will learn how to read and write text files using non buffered and buffered File I/O classes, then learn how to parse a String into tokens using the String split() method, and finally, how to handle exceptions using various approaches. Part 2: Reading and Writing JSON Files. In this activity, you will learn how to read, write, and serialize JSON files to and from Java Objects. Refer to the instructions within "Activity 4 Guide" to complete the assignment. APA style is not required, but solid academic writing is expected. This assignment uses a rubric. Please review the rubric prior to beginning the assignment to become familiar with the expectations for successful…arrow_forward
- In c++ Create a new project named lab9_2. You will continue to use the Courses class, but this time you will create a vector of Courses. The file you will read from is below: 6CSS 2A 1111 35CSS 2A 2222 20CSS 1 3333 40CSS 1 4444 33CSS 3 5555 15CSS 44 6666 12 Read this information into a vector of Courses. Then, print out a summary of your vector. Here's a sample driver: #include <iostream>#include <string>#include <fstream>#include <vector>#include <cstdlib>#include "Course.h"using namespace std;int main(){vector<Course> myclass;string dep, c_num;int classes, sec, num_stus;ifstream fin("sample.txt");if (fin.fail()){cout << "File path is bad\n";exit(1);}fin >> classes;for (int i = 0; i < classes; i++){fin >> dep >> c_num >> sec >> num_stus;// Now how do you create a Course object// that contains the information you just read in// and add it to your myclass vector?}cout << "Here are the college courses: "…arrow_forwardcreateDatabaseOfProfiles(String filename) This method creates and populates the database array with the profiles from the input file (profile.txt) filename parameter. Each profile includes a persons' name and two DNA sequences. 1. Reads the number of profiles from the input file AND create the database array to hold that number profiles. 2. Reads the profiles from the input file. 3. For each person in the file 1. creates a Profile object with the information from file (see input file format below). 2. insert the newly created profile into the next position in the database array (instance variable).arrow_forwardsave_compressed_image: takes a nested list and a filename (string) as input, and saves it in the compressed PGM format to a file with the given filename. If the image matrix given as input is not a valid compressed PGM image matrix, instead raise a AssertionError with an appropriate error message. >>> save_compressed_image([["0x5", "200x2"], ["111x7"]], "test.pgm.compressed") >>> fobj open("test.pgm.compressed", 'r') >>> fobj.read() = 'P2C\\n7_2\\n255\\n0x5 200x2\\n111x7\\n' >>> fobj.close() >>> image [["0x5", "200x2"], ["111x7"]] >>> save_compressed_image(image, "test.pgm") >>> image2 = >>> image True = == load_compressed_image("test.pgm") image2 • save_image: takes a nested list and a filename (string) as input. Checks the type of elements in the list If thou are intogors thon saves the posted list as a PCM imago matrix into a file with the givenarrow_forward
- Required information id fname lname company address city ST zip 103 Art Venere 8 W Cerritos Ave #54 Bridgeport NJ 8014 104 Lenna Paprocki Feltz Printing 639 Main St Anchorage AK 99501arrow_forwardYour goal is to implement an application that reads a file, modify its content, and writes the modification back to the same file. The file includes 2 lines of integers. The first line indicates which integer on the second line has been selected (active). And the second line lists all the integers in the list (maximum of 10). Your application should have a menu that is constantly displayed on the screen (see the menu below). Right below the menu, the program should display list of all integers in the file (second line). Also, it should show which integer is currently selected (active) by displaying an arrow to its left. The user should be able to select a menu item by entering its associated key and pressing the Enter key on the keyboard. “Select Down” selects the next item in the list. If the item at the end of the list is selected, this option selects the first item in the list. “Select Up” selects the previous item in the list. If the first item is selected, this option selects the…arrow_forwardAdd each element in origList with the corresponding value in offsetAmount. Print each sum followed by a space. Ex: If origList = {40, 50, 60, 70} and offsetAmount = {5, 7, 3, 0}, print: 45 57 63 70 #include <iostream>#include <vector>using namespace std; int main() {const int NUM_VALS = 4;vector<int> origList(NUM_VALS);vector<int> offsetAmount(NUM_VALS);unsigned int i; for (i = 0; i < origList.size(); ++i) {cin >> origList.at(i);} for (i = 0; i < offsetAmount.size(); ++i) {cin >> offsetAmount.at(i);} cout << endl; return 0;} Please help me with this problem using c++.arrow_forward
- ReadInstructor. The class will: – Create an array of instructor objects – Read the instructors.txt file – Create an Instructor object for each line of input and store the object in the array. – After closing the file, it will print out a line for each instructor in the array. Input file:Mary Smith 1991 50000.00 John Jones 2000 90000.00 Terry Seidel 1992 51000.00 Jessica Terrell 2000 91000.00arrow_forwardadd a menu that you design which includes these features: Ability for a user to input a set of grades into a vector. Make sure only integers between 0 and 100 are used. Cout the vector onto the screen with grades separated by spaces and starting with, "Original user vector: " Output the average grade. Ability to sort the user-inputted vector from low to high or high to low. Cout the new sorted vector onto the screen with grades separated by spaces and starting with, "Grades sorted vector: " Using the binary search method (not the linear search method), add the ability to find a user selected grade and change it.arrow_forwardJQuery loading Consider following code $(function(){ // jQuery methods go here... }); What is the purpose of this code with respect to JQuery ? O This is to prevent any jQuery code from running before the document is finished loading (is ready). O This is to load the jQuery and to run this as soon as page start before loading. This is to load the function so we can run jQuery codearrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education

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