0,0 > 0,1 > 0,2 > 1,2 > 2,2 > 2,1 > 2,0 > 3,0 > 4,0 > 4,1 > 4,2 > 4,3 0,0 > 0,1 > 0,2 > 1,2 > 2,2 > 2,1 > 2,0 > 3,0 > 4,0 > 4,1 > 5,1 > 5,2 > 4,2 > 4,3 0,0 > 0,1 > 0,2 > 1,2 > 2,2 > 2,1 > 2,0 > 3,0 > 4,0 > 5,0 > 5,1 > 5,2 > 4,2 > 4,3 0,0 > 0,1 > 0,2 > 1,2 > 2,2 > 2,1 > 2,0 > 3,0 > 4,0 > 5,0 > 5,1 > 4,1 > 4,2 > 4,3

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Can you explain the output

1
#include <iostream>
#include <string>
4
const int WIDTH = 6;
5
const int HEIGHT = 5;
7- void check(int x, int y, int dest_x, int dest_y
8 -
int (&maze)[HEIGHT][WIDTH], std
::string& path) {
if (x < 0 || y < 0 || x >= WIDTH|| y >=
HEIGHT || ! maze[y][x]) {
9 -
10
return;
11
}
12
int len = path.size();
13
path +=
(char) ('0' + x);
14
path += ',';
15
path
(char) ('0' + y);
16
17 -
if (x == dest_x && y ==
dest_y) {
18
std::cout <<
path << "\n";
19 -
} else {
path += " > ";
maze[y][x] = 0;
check (x + 0, y - 1, dest_x, dest_y, maze,
20
21
22
path);
check (x + 0, y + 1, dest_x, dest_y, maze,
path);
check (x - 1, y + 0, dest_x, dest_y, maze,
path);
check (x + 1, y + 0, dest_x, dest_y, maze,
23
24
25
path);
26
maze[y][x] = 1;
27
}
28
29
path.resize(1len);
30 }
31
32
33 - int main() {
34 -
int maze[HEIGHT][WIDTH] = {
35
{1,0,1,1,1,1},
36
{1,0,1,0,1,1},
37
{1,1,1,0,1,1},
38
{0,0,0,0,1,0},
39
{1,1,1,0,1,1}};
40
41
std::string path;
42
check(0, 0, 4, 3, maze, path);
43
return 0;
44 }
Transcribed Image Text:1 #include <iostream> #include <string> 4 const int WIDTH = 6; 5 const int HEIGHT = 5; 7- void check(int x, int y, int dest_x, int dest_y 8 - int (&maze)[HEIGHT][WIDTH], std ::string& path) { if (x < 0 || y < 0 || x >= WIDTH|| y >= HEIGHT || ! maze[y][x]) { 9 - 10 return; 11 } 12 int len = path.size(); 13 path += (char) ('0' + x); 14 path += ','; 15 path (char) ('0' + y); 16 17 - if (x == dest_x && y == dest_y) { 18 std::cout << path << "\n"; 19 - } else { path += " > "; maze[y][x] = 0; check (x + 0, y - 1, dest_x, dest_y, maze, 20 21 22 path); check (x + 0, y + 1, dest_x, dest_y, maze, path); check (x - 1, y + 0, dest_x, dest_y, maze, path); check (x + 1, y + 0, dest_x, dest_y, maze, 23 24 25 path); 26 maze[y][x] = 1; 27 } 28 29 path.resize(1len); 30 } 31 32 33 - int main() { 34 - int maze[HEIGHT][WIDTH] = { 35 {1,0,1,1,1,1}, 36 {1,0,1,0,1,1}, 37 {1,1,1,0,1,1}, 38 {0,0,0,0,1,0}, 39 {1,1,1,0,1,1}}; 40 41 std::string path; 42 check(0, 0, 4, 3, maze, path); 43 return 0; 44 }
0,0 > 0,1 > 0,2 > 1,2 > 2,2 > 2,1 > 2,0 > 3,0 > 4,0 >
4,1 > 4,2 > 4,3
0,0 > 0,1 > 0,2 > 1,2 > 2,2 > 2,1 > 2,0 > 3,0 > 4,0 >
4,1 > 5,1 > 5,2 > 4,2 > 4,3
0,0 > 0,1 > 0,2 > 1,2 > 2,2 > 2,1 > 2,0 > 3,0 > 4,0 >
5,0 > 5,1 > 5,2 > 4,2 > 4,
.3
0,0 > 0,1 > 0,2 > 1,2 > 2,2 > 2,1 > 2,0 > 3,0 > 4,0 >
5,0 > 5,1 > 4,1 > 4,2 > 4,3
|
Transcribed Image Text:0,0 > 0,1 > 0,2 > 1,2 > 2,2 > 2,1 > 2,0 > 3,0 > 4,0 > 4,1 > 4,2 > 4,3 0,0 > 0,1 > 0,2 > 1,2 > 2,2 > 2,1 > 2,0 > 3,0 > 4,0 > 4,1 > 5,1 > 5,2 > 4,2 > 4,3 0,0 > 0,1 > 0,2 > 1,2 > 2,2 > 2,1 > 2,0 > 3,0 > 4,0 > 5,0 > 5,1 > 5,2 > 4,2 > 4, .3 0,0 > 0,1 > 0,2 > 1,2 > 2,2 > 2,1 > 2,0 > 3,0 > 4,0 > 5,0 > 5,1 > 4,1 > 4,2 > 4,3 |
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY