CLRS
CLRS copied to clipboard
Error in 22.1-1
check stackoverflow
I agree with you @zjplab . My approach is adding out-degree and in-degree attributes to each vertices just like PI and D attributes and calculate the value while searching the Graphs only. So we need to initialize these attributes just like we initialize PI and D attributes value. So that's O(V). And searching part of BFS takes O(E) time. Hence total of O(V+E). Hope this helps.