Skip to content

Commit 969784d

Browse files
authored
Refine descriptions of BFS and DFS algorithms
1 parent b6d1d0b commit 969784d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

notes/graphs.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ So the precise way to answer that question is:
333333

334334
#### Breadth-First Search (BFS)
335335

336-
Breadth-First Search (BFS) is a fundamental graph traversal algorithm that explores a graph **level by level** from a specified start vertex. It first visits all vertices at distance 1 from the start, then all vertices at distance 2, and so on. This makes BFS the natural choice whenever “closest in number of edges” matters.
336+
Breadth-First Search (BFS) is a graph traversal algorithm that explores a graph **level by level** from a specified start vertex. It first visits all vertices at distance 1 from the start, then all vertices at distance 2, and so on. This makes BFS the natural choice whenever “closest in number of edges” matters.
337337

338338
To efficiently keep track of the traversal, BFS employs two primary data structures:
339339

@@ -450,7 +450,7 @@ Shortest path A→E: backtrack E→C→A ⇒ A - C - E
450450

451451
#### Depth-First Search (DFS)
452452

453-
Depth-First Search (DFS) is a fundamental graph traversal algorithm that explores **as far as possible** along each branch before backtracking. Starting from a source vertex, it dives down one neighbor, then that neighbor’s neighbor, and so on—only backing up when it runs out of new vertices to visit.
453+
Depth-First Search (DFS) is a graph traversal algorithm that explores **as far as possible** along each branch before backtracking. Starting from a source vertex, it dives down one neighbor, then that neighbor’s neighbor, and so on—only backing up when it runs out of new vertices to visit.
454454

455455
To track the traversal efficiently, DFS typically uses:
456456

0 commit comments

Comments
 (0)