Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to check if the current cell matches the current character of the word.
DSA C#
if (board[row, col] == word[[1]]) { // proceed }
Attempts:
3 left
💡 Hint
Common Mistakes
Using row or col instead of the word index.
Using word.Length which is out of range.
✗ Incorrect
We compare the board cell with the character at the current index in the word.
2fill in blank
mediumComplete the code to mark the current cell as visited.
DSA C#
visited[row, col] = [1];Attempts:
3 left
💡 Hint
Common Mistakes
Marking visited as false instead of true.
Using null or 0 which are invalid for boolean arrays.
✗ Incorrect
We mark the cell as visited by setting it to true.
3fill in blank
hardFix the error in the recursive call to explore neighbors.
DSA C#
bool found = DFS(board, word, row + [1], col, index + 1, visited) || DFS(board, word, row - 1, col, index + 1, visited);
Attempts:
3 left
💡 Hint
Common Mistakes
Using -1 to move down which actually moves up.
Using 0 which does not move.
✗ Incorrect
We move down by adding 1 to the row index.
4fill in blank
hardFill both blanks to check boundaries and visited status before recursion.
DSA C#
if (row >= 0 && row < board.GetLength(0) && col >= 0 && col < board.GetLength(1) && !visited[[1], [2]]) { // safe to explore }
Attempts:
3 left
💡 Hint
Common Mistakes
Using index or word instead of row and col for visited check.
Mixing row and col order.
✗ Incorrect
We check if the cell at (row, col) is not visited before exploring.
5fill in blank
hardFill all three blanks to backtrack correctly after exploring neighbors.
DSA C#
visited[[1], [2]] = [3];
Attempts:
3 left
💡 Hint
Common Mistakes
Setting visited to true again instead of false.
Using wrong indices for visited.
✗ Incorrect
After exploring, mark the cell as not visited (false) to allow other paths.
