Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to check if the rat can move to the next cell safely.
DSA C
int isSafe(int maze[4][4], int x, int y) { if (x >= 0 && x < 4 && y >= 0 && y < 4 && maze[x][y] == [1]) { return 1; } return 0; }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 0 instead of 1 to check for open path.
Not checking boundaries correctly.
✗ Incorrect
The rat can move only to cells with value 1, which means the path is open.
2fill in blank
mediumComplete the code to mark the current cell as part of the solution path.
DSA C
solution[x][y] = [1]; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Marking with 0 which means no path.
Using negative values which are invalid.
✗ Incorrect
Marking the cell with 1 means it is part of the solution path.
3fill in blank
hardFix the error in the recursive call to move right in the maze.
DSA C
if (solveMazeUtil(maze, x + [1], y, solution)) { return 1; }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 0 which means no movement.
Using -1 which moves left instead of right.
✗ Incorrect
To move right, increase x by 1.
4fill in blank
hardFill both blanks to move down and backtrack correctly.
DSA C
if (solveMazeUtil(maze, x, y + [1], solution)) { return 1; } else { solution[x][y] = [2]; return 0; }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using -1 to move down which moves up instead.
Not resetting the solution cell during backtracking.
✗ Incorrect
Moving down increases y by 1; backtracking resets solution[x][y] to 0.
5fill in blank
hardFill all three blanks to check the base case and start the solution.
DSA C
if (x == [1] - 1 && y == [2] - 1 && maze[x][y] == [3]) { solution[x][y] = 1; return 1; }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 5 which is out of maze bounds.
Checking for 0 instead of 1 in the last cell.
✗ Incorrect
The maze size is 4x4, so last cell is at index 3 (4-1). The cell must be 1 to be valid.