Logo
Grokking the Coding Interview: Patterns for Coding Questions
Ask Author
Back to course home

0% completed

Graph Traversal - Depth First Search(DFS)

A graph consists of vertices (nodes) connected by edges (lines). Graph traversal involves visiting all the graph nodes following a specific strategy or order. During traversal, each node is typically marked as visited to avoid revisiting the same node multiple times and to prevent infinite loops in cyclic graphs.

There are two common graph traversal algorithms: Depth-First Search (DFS) and Breadth-First Search (BFS). Let's briefly discuss each of them:

.....

.....

.....

Like the course? Get enrolled and start learning!