Ask your own question, for FREE!
Computer Science 13 Online
OpenStudy (anonymous):

breadth first search: BFS(G, s) { initialize vertices; Q = {s}; // Q is a queue (duh); initialize to s while (Q not empty) { u = RemoveTop(Q); for each v  u->adj { if (v->color == WHITE) v->color = GREY; v->d = u->d + 1; v->p = u; Enqueue(Q, v); } u->color = BLACK; } }

OpenStudy (anonymous):

@rebeccaskell94 here is one algorithm :)

OpenStudy (anonymous):

nice implication.. you can also try it with 2d arrays ;)

OpenStudy (anonymous):

yes i know but it'll be tough and besides its just an algorithm :)

OpenStudy (anonymous):

yeahp, but from my experience, i found it much easier when i tried to represent graphs as 2d arrays...

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!