3. What will be the output of the following code snippet for the Rat in a Maze problem?
int maze[4][4] = {
{1, 0, 0, 0},
{1, 1, 0, 1},
{0, 1, 0, 0},
{1, 1, 1, 1}
};
int solution[4][4] = {0};
int solveMaze(int maze[4][4], int x, int y, int solution[4][4]) {
if (x == 3 && y == 3 && maze[x][y] == 1) {
solution[x][y] = 1;
return 1;
}
if (x >= 0 && x < 4 && y >= 0 && y < 4 && maze[x][y] == 1) {
solution[x][y] = 1;
if (solveMaze(maze, x + 1, y, solution)) return 1;
if (solveMaze(maze, x, y + 1, solution)) return 1;
solution[x][y] = 0;
return 0;
}
return 0;
}
int main() {
if (solveMaze(maze, 0, 0, solution)) {
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
printf("%d ", solution[i][j]);
}
printf("\n");
}
} else {
printf("No path found\n");
}
return 0;
}