Graph

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/7

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 3:10 PM on 3/27/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

8 Terms

1
New cards
<p><strong>Number of Islands</strong></p>

Number of Islands

DFS/BFS on grid:

  1. Iterate all cells

  2. If land ('1'), run DFS/BFS to mark entire island as visited

  3. Increment count

    Turn visited land into water or use visited set

2
New cards
<p><strong>Flood Fill</strong></p>

Flood Fill

DFS/BFS from starting pixel:

  1. If new color == original, return

  2. Traverse neighbors (4 directions)

  3. Recolor all connected same-color cells

3
New cards
<p><strong>01 Matrix (Multi-source BFS)</strong></p>

01 Matrix (Multi-source BFS)

BFS from all 0s:

  1. Push all 0 cells into queue

  2. Initialize others as ∞

  3. BFS outward, updating distance = prev + 1

    Shortest distance to nearest 0

4
New cards
<p><strong>Rotting Oranges (Multi-source BFS)</strong></p>

Rotting Oranges (Multi-source BFS)

BFS from all rotten oranges:

  1. Push all rotten (2) into queue

  2. Count fresh oranges

  3. Each level = 1 minute, rot neighbors

  4. Decrease fresh count

  5. If fresh becomes 0 → return minutes, else -1

5
New cards
<p><strong>Clone Graph</strong></p>

Clone Graph

DFS/BFS + hashmap:

  1. Map original node → cloned node

  2. For each node, clone neighbors recursively

  3. Avoid revisiting using map

    Graph copy via mapping

6
New cards
<p><strong>Pacific Atlantic Water Flow</strong></p>

Pacific Atlantic Water Flow

Reverse DFS/BFS:

  1. Start from ocean edges (Pacific & Atlantic separately)

  2. Move inward only to higher/equal heights

  3. Mark reachable cells for each ocean

  4. Intersection = answer

7
New cards
<p><strong>Course Schedule</strong></p>

Course Schedule

Cycle detection in directed graph:

  1. Build adjacency list

  2. DFS with 3 states: unvisited, visiting, visited

  3. If visiting node seen again → cycle

  4. If no cycle → possible to finish

    Topological sort concept

8
New cards
<p><strong>Max Area of Island</strong></p>

Max Area of Island

DFS/BFS on grid:

  1. Iterate all cells

  2. If land (1), run DFS/BFS to explore connected island

  3. Count number of cells in this island

  4. Track maximum area seen

    Mark visited by turning land to water or using visited set

Explore top notes

note
Implications of wider issue
Updated 611d ago
0.0(0)
note
The German Revolution (1918-1919)
Updated 842d ago
0.0(0)
note
Chapter 20: Carbohydrates
Updated 1267d ago
0.0(0)
note
Traditional Music (AQA)
Updated 633d ago
0.0(0)
note
Transport in Plants
Updated 899d ago
0.0(0)
note
Implications of wider issue
Updated 611d ago
0.0(0)
note
The German Revolution (1918-1919)
Updated 842d ago
0.0(0)
note
Chapter 20: Carbohydrates
Updated 1267d ago
0.0(0)
note
Traditional Music (AQA)
Updated 633d ago
0.0(0)
note
Transport in Plants
Updated 899d ago
0.0(0)