Medium

Depth First Search

Depth-first search follows one neighbor as far as it can, then backtracks. With an adjacency list it looks at each vertex and each edge a constant number of times.

Costs

CategoryAlgorithm
DifficultyMedium
Time, adjacency listO(V + E)
Time, adjacency matrixO(V²)
StackO(V)

Questions

What is Depth First Search?

Depth-first search follows one neighbor as far as it can, then backtracks. With an adjacency list it looks at each vertex and each edge a constant number of times.

Where do I practice it?

DSA Master keeps challenges and progress on the phone. This page is the idea and the costs.