RK DSA Studio

Topological sort

Order directed acyclic graph vertices so each edge goes from earlier to later. Repeatedly remove zero-indegree vertices.

Remember: No prerequisites left → ready.

Example: A → B → C requires A before B before C.

Time: O(V + E). Auxiliary space: O(V).

Formula: Remove indegree-0 vertices; processed < V implies a cycle

Up to 8 unique integer vertex labels and 16 edges. Edges: from,to; separate edges with semicolons. Directed graph. Check all components. Graph storage O(V + E) is excluded from auxiliary space.

Complexities describe the underlying algorithm; tutorial snapshots and rendering can use additional resources.

The interactive workspace loads here when JavaScript is available. You can still browse the learning notes and links above without it.