Recall & Review
beginner
What is the main idea behind using backtracking for word search in a grid?
Backtracking tries all possible paths in the grid to find the word by moving step-by-step and undoing moves if they don't lead to a solution.
Click to reveal answer
beginner
In a word search grid, how do we ensure we don't use the same cell twice in one word path?
We mark the cell as visited during the current path and unmark it when backtracking to allow other paths to use it.
Click to reveal answer
beginner
What directions are typically checked when searching for the next character in the grid?
We check up, down, left, and right neighbors of the current cell to find the next character.
Click to reveal answer
intermediate
Why is backtracking suitable for word search problems in grids?
Because it explores all possible paths systematically and stops when the word is found or all options are exhausted.
Click to reveal answer
intermediate
What is the base case in the recursive backtracking function for word search?
The base case is when all characters of the word have been matched successfully, meaning the word is found.
Click to reveal answer
Which of the following is NOT a valid move when searching for the next character in the grid?
✗ Incorrect
Typically, only up, down, left, and right moves are allowed, not diagonal moves.
What should you do if the current cell's character does not match the word's current character?
✗ Incorrect
If the character does not match, backtracking means undoing the current step and trying other paths.
How do you prevent revisiting the same cell in the current search path?
✗ Incorrect
Cells are marked visited only during the current path and unmarked when backtracking.
What does the backtracking function return when the entire word is found?
✗ Incorrect
It returns true to indicate the word has been found.
Which data structure is commonly used to keep track of visited cells in the grid?
✗ Incorrect
A 2D boolean array matching the grid size is used to mark visited cells.
Explain how backtracking works to find a word in a grid step-by-step.
Think about trying paths and undoing moves if they don't work.
You got /6 concepts.
Describe how you would implement a function to check if a word exists in a grid using backtracking.
Focus on recursion and visited tracking.
You got /6 concepts.