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, marking them visited 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 connected land cells around the starting point before moving deeper.
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 order of discovery.
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 nodes in order of discovery.
Why do we mark cells as visited during traversal?
✗ Incorrect
Marking visited cells prevents revisiting and infinite loops.
If a grid has no '1's, what is the number of islands?
✗ Incorrect
No land means zero islands.
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 difference between BFS and DFS when solving the Number of Islands problem.
Focus on the order of visiting neighbors.
You got /4 concepts.