Medium

Topological Sort

A topological order lists every vertex before the vertices it points to. It exists only for a directed acyclic graph. Kahn’s algorithm removes vertices with no incoming edge.

Costs

CategoryAlgorithm
DifficultyMedium
Time, adjacency listO(V + E)
Requiresa directed acyclic graph
A cycleno topological order

Questions

What is Topological Sort?

A topological order lists every vertex before the vertices it points to. It exists only for a directed acyclic graph. Kahn’s algorithm removes vertices with no incoming edge.

Where do I practice it?

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