Grokking Graph Algorithms for Coding Interviews
Ask Author
Back to course home

0% completed

Vote For New Content
Example is wrong?

makarand.h

Nov 16, 2024

In the below example given in the text, 6 needs to come after both 2, and 0 because it depends on both. But in Order 1 and Order 3, 6 comes before 0.

Text Snippet:

Consider the following Directed Acyclic Graph (DAG):

5 7 / \ / \ 2 0 3 4 \ / / \ 6 1 8

In this graph, there are several possible topological sorts:

  1. Order 1: 7, 5, 2, 6, 3, 1, 0, 4, 8
  2. Order 2: 7, 5, 2, 3, 1, 0, 4, 6, 8
  3. Order 3: 5, 7, 3, 2, 1, 6, 0, 4, 8

1

0

Comments
Comments

On this page