Recall & Review
beginner
What is topological sorting?
Topological sorting is a way to arrange the nodes of a directed graph in a linear order so that for every directed edge from node A to node B, A comes before B in the order.
Click to reveal answer
beginner
Which type of graph can have a topological sort?
Only directed acyclic graphs (DAGs) can have a topological sort because cycles would make it impossible to order nodes without conflicts.
Click to reveal answer
intermediate
Why can't graphs with cycles be topologically sorted?
Because in a cycle, nodes depend on each other in a loop, so there is no way to order them linearly without breaking the dependency.
Click to reveal answer
intermediate
Name two common algorithms used for topological sorting.
The two common algorithms are Kahn's algorithm and Depth-First Search (DFS) based algorithm.
Click to reveal answer
beginner
Give a real-life example where topological sorting is useful.
Topological sorting is useful in scheduling tasks where some tasks must be done before others, like building a house where the foundation must be done before walls.
Click to reveal answer
Which graph property is required for topological sorting?
✗ Incorrect
Topological sorting only works on directed acyclic graphs (DAGs).
What does a topological sort of a graph represent?
✗ Incorrect
It arranges nodes so that all dependencies come before dependent nodes.
Which algorithm is NOT used for topological sorting?
✗ Incorrect
Dijkstra's algorithm is for shortest paths, not topological sorting.
What happens if you try to topologically sort a graph with a cycle?
✗ Incorrect
Cycles prevent a linear ordering that respects dependencies.
In a task scheduling scenario, what does topological sorting help with?
✗ Incorrect
It ensures tasks are done only after their prerequisites.
Explain what topological sorting is and why it requires a directed acyclic graph.
Think about ordering tasks with dependencies and why loops cause problems.
You got /4 concepts.
Describe two algorithms used for topological sorting and how they generally work.
One uses removing nodes step-by-step, the other uses depth-first search.
You got /4 concepts.