IntermediateAbout 25 min

    Topological Sort

    Read the full article on Substack

    5 min read.

    Order tasks with dependencies! Visualize Kahn's Algorithm using In-Degrees. Crucial for build systems, course scheduling, and resolving dependencies.

    Think of it this way: Think of getting dressed. You must put on socks before shoes, and underwear before pants. You can't just put things on in random order; dependencies must be respected.

    Ain 0Bin 1Cin 1Din 2Ein 1Fin 1
    queue
    order

    Count each node’s incoming edges.

    1/15

    Check your understanding

    Answer from memory before you scroll back up. Pulling an idea out of your head is what makes it stay there.

    Kahn’s algorithm

    Sequence

    Order the steps of a topological sort by in-degree.

    Tap a piece, then tap where it goes — or drag it. Tap the tray to take one back.

    1. 1Drop a step here
    2. 2Drop a step here
    3. 3Drop a step here
    4. 4Drop a step here
    5. 5Drop a step here
    5 pieces left to place

    Quiz

    20 questions
    Question 1 of 20
    Score: 0

    Topological Sort is only possible for which type of graph?

    Done with this lesson?

    Sign in free to keep your progress, streak and quiz scores.

    Keep going