walkccc / CLRS

📚 Solutions to Introduction to Algorithms Third Edition
https://walkccc.me/CLRS
MIT License
4.63k stars 1.26k forks source link

Exercise 25.2-5 #427

Open Arshaan-256 opened 2 years ago

Arshaan-256 commented 2 years ago

The solution for this question is wrong. For my Algorithm course, I was asked to provide a counterexample to show that the given equation is wrong. And I think, my solution provides enough insight.

image

In the given example, you can see that no path exists between i and j for k=2, and k=3. Therefore d^(k-1)_i,j and d^(k)_i,j both are equal to infinity. And the correct pi value must be NIL. But if we were to follow the equation given in the recurrence, we get pi^(k)_i,j = pi^(k)_3,j = 3 instead.