Recall & Review
beginner Click to reveal answer
What is the main idea behind backtracking in word search problems?
Backtracking tries to build a solution step-by-step and abandons a path as soon as it determines that this path cannot lead to a valid solution.
beginner Click to reveal answer
In a word search grid, how do you decide the next cell to explore during backtracking?
You explore adjacent cells (up, down, left, right) that match the next character in the word and have not been visited yet.
beginner Click to reveal answer
Why do we mark cells as visited during backtracking in word search?
To avoid revisiting the same cell in the current search path, which prevents cycles and incorrect matches.
beginner Click to reveal answer
What is the base case for the recursive backtracking function in word search?
The base case is when all characters of the word have been matched successfully, meaning the word is found in the grid.
intermediate Click to reveal answer
How does backtracking ensure all possible paths are checked in the grid?
By exploring all valid adjacent cells recursively and backtracking when a path fails, it systematically checks every possible path.
Which directions are typically checked when searching for the next character in a word search grid?
✗ Incorrect
In word search backtracking, we check all four directions: up, down, left, and right.
What should you do if the current cell's character does not match the expected character in the word?
✗ Incorrect
If the character does not match, backtracking means stopping this path and returning to try other paths.
Why is it important to unmark a cell as visited when backtracking?
✗ Incorrect
Unmarking allows other search paths to use the cell again, ensuring all possibilities are explored.
What does the backtracking function return when the word is found?
✗ Incorrect
The function returns true to indicate the word has been found successfully.
What is the time complexity of the word search backtracking algorithm in the worst case?
✗ Incorrect
Each cell can lead to up to 3 directions (excluding the previous cell), repeated for each character in the word.
Explain how backtracking works to find a word in a 2D grid.
Think about trying paths step-by-step and undoing choices when stuck.
You got /6 concepts.
Describe the role of the visited cells array in the word search backtracking algorithm.
Why can't you use the same letter cell twice in one word search path?
You got /4 concepts.
