🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Closures and Warshall's Algorithm: all 10 questions

Quiz: Closures and Warshall's Algorithm · Question 6 of 10

What is the Warshall update rule from Wₖ₋₁ to Wₖ?

What is the Warshall update rule from Wₖ₋₁ to Wₖ?

  1. A.Wₖ[i][j] = Wₖ₋₁[i][k] AND Wₖ₋₁[k][j]
  2. B.Wₖ[i][j] = Wₖ₋₁[j][i]
  3. C.Wₖ[i][j] = Wₖ₋₁[i][j] AND Wₖ₋₁[k][k]
  4. D.Wₖ[i][j] = Wₖ₋₁[i][j] OR (Wₖ₋₁[i][k] AND Wₖ₋₁[k][j])
Answer & explanation

Correct answer: Wₖ[i][j] = Wₖ₋₁[i][j] OR (Wₖ₋₁[i][k] AND Wₖ₋₁[k][j])

Keep old paths, and add a path i → k → j that uses k as a middle stop.

Can you get the rest right without peeking?

Take the timed Quiz: Closures and Warshall's Algorithm quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →