You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Performance wise both methods have approximately same levels since operating system uses stack anyways
Topological Sort (Ordering)
Topological ordering of a directed graph is a linear ordering of its vertices such that every directed edge uv from vertex u to vertex v, u comes BEFOREv in ordering
In layman terms, the graph should be directed
There's a order or flow in the which the traversals occurs
No directed cycles in the graph either (No DAG - Directed Acyclic Graphs)
Linear time complexity
Example:
Project management
Dependency injections
Task scheduling
Constructing the syllabus
Hamiltonian path: it is a path in an undirected/directed graph where every node is visited exactly once
If this path exists, then the Topological order is unique for the graph
And if the starting and ending vertex are the same, then it's called Hamiltonian cycle
find Hamiltonian path is a NP-complete problem (so its difficult to find the path when the size increases, but we can determine whether such path exists in linear time)
Basic Algorithm (pen-paper) is
find a vertex that has no incoming edges
remove all its outgoing edges
print the vertex
keep repeating it over and over again till the graph is empty
If there exist no vertex which has zero incoming edges, it means that the graph is a cyclic graph