Which of the following is/are the results of the topological

Which of the following is/are the results of the topological sorting of the graph?

  1. A.

    2, 8, 0, 7, 1, 3, 5, 6, 4, 9, 10, 11, 12

  2. B.

    2, 8, 7, 0, 6, 9, 11, 12, 10, 1, 3, 5, 4

  3. C.

    8, 2, 7, 0, 6, 9, 10, 11, 12, 1, 3, 5, 4

  4. D.

    All the above

Attempted by 68 students.

Show answer & explanation

Correct answer: D

Topological ordering of a directed graph is a linear ordering of its vertices such that for every directed edge (u, v) from vertex u to vertex v, u comes before v in the ordering.

Key precedence constraints visible in the graph:

  • 8 comes before 7, and 7 comes before 6 (8 → 7 → 6).

  • 0 comes before 1, before 5, and before 6 (0 → 1, 0 → 5, 0 → 6).

  • 2 comes before 3, and 3 comes before 5 (2 → 3 → 5).

  • Both 5 and 6 come before 4 (5 → 4 and 6 → 4).

  • 6 comes before 9; 9 comes before 10, 11 and 12; and 11 comes before 12 (6 → 9 → {10, 11, 12}, 11 → 12).

Check each candidate ordering against these constraints:

  • Sequence: 2, 8, 0, 7, 1, 3, 5, 6, 4, 9, 10, 11, 12 — All required precedences hold: 8 before 7 before 6; 0 before 1,5,6; 2 before 3 before 5; 5 and 6 before 4; and 6 before 9 then 10,11,12 with 11 before 12.

  • Sequence: 2, 8, 7, 0, 6, 9, 11, 12, 10, 1, 3, 5, 4 — All required precedences hold: 8 → 7 → 6; 0 is before its successors; 2 → 3 → 5; 5 and 6 before 4; and 6 → 9 → 10/11/12 with 11 → 12.

  • Sequence: 8, 2, 7, 0, 6, 9, 10, 11, 12, 1, 3, 5, 4 — All required precedences hold: 8 → 7 → 6; 0 before its successors; 2 → 3 → 5; 5 and 6 before 4; and 6 → 9 → 10/11/12 with 11 → 12.

Conclusion: Each listed sequence satisfies every directed edge constraint, so all three are valid topological orderings. Therefore, the answer 'All the above' is correct.

Explore the full course: Dsssb Tgt Computer Science Paper 2