🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Topological Sort: all 15 questions

Quiz: Topological Sort · Question 5 of 15

In the course problem, the pair [a, b] means "to take course a, first take course b". Which edge do you add?

In the course problem, the pair [a, b] means "to take course a, first take course b". Which edge do you add?

  1. A.a → b
  2. B.b → a
  3. C.both directions
  4. D.no edge, just a counter
Answer & explanation

Correct answer: b → a

The prerequisite b must come first, so the edge points from b to a and indeg[a] increases.

Can you get the rest right without peeking?

Take the timed Quiz: Topological Sort quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →