Topological Sort – Kahn’s Algorithm

Problem Statement:

Perform a Topological Sort of a Directed Acyclic Graph (DAG) using Kahn’s Algorithm.

Steps: Start with nodes having indegree 0 → remove → reduce neighbors indegree → continue.

Queue

Output Order

Step 0: Compute indegrees and push nodes with indegree 0 into queue.