Recall & Review
beginner
What is the main goal of the Number of Islands problem?
To count how many separate groups of connected '1's (land) exist in a 2D grid of '1's and '0's (land and water).
Click to reveal answer
intermediate
How does Depth-First Search (DFS) help solve the Number of Islands problem?
DFS explores all connected land cells from a starting point by going deep into neighbors recursively, marking visited cells to avoid counting the same island multiple times.
Click to reveal answer
intermediate
How does Breadth-First Search (BFS) differ from DFS in this problem?
BFS explores neighbors level by level using a queue, visiting all adjacent land cells before moving deeper, but both BFS and DFS mark visited cells to count islands correctly.
Click to reveal answer
beginner
What data structure is commonly used to keep track of cells to visit in BFS for Number of Islands?
A queue is used to store cells to visit next in BFS, ensuring neighbors are processed in the order they are discovered.
Click to reveal answer
beginner
Why do we mark cells as visited in Number of Islands algorithms?
Marking cells as visited prevents counting the same land cell multiple times and avoids infinite loops during traversal.
Click to reveal answer
In the Number of Islands problem, what does a '1' represent in the grid?
✗ Incorrect
'1' represents land cells where islands can form.
Which traversal method uses a stack or recursion to explore deep into neighbors?
✗ Incorrect
DFS uses recursion or a stack to explore neighbors deeply.
What data structure does BFS use to keep track of nodes to visit next?
✗ Incorrect
BFS uses a queue to process neighbors in order.
Why do we mark cells as visited during traversal?
✗ Incorrect
Marking visited cells prevents revisiting and infinite loops.
Which of these is NOT a valid neighbor direction in Number of Islands problem?
✗ Incorrect
Only up, down, left, and right neighbors are considered, not diagonal.
Explain how DFS can be used to count the number of islands in a grid.
Think about exploring deep into connected land cells.
You got /4 concepts.
Describe the steps BFS follows to find all cells of an island in the grid.
Focus on level-by-level exploration using a queue.
You got /5 concepts.