Ask your own question, for FREE!
MIT 6.00 Intro Computer Science (OCW) 18 Online
OpenStudy (anonymous):

PS 11. Does anybody solved the PS such as it passes all the tests? Example: A->B 10 A->C 3 C->B 3 B->D 1 B->D 6 Looking for path from A to D. Optimal: A->C->B->D with weight 7 If B was visited before C (B is in "visited" list) we will get A->C->D with weight 9 that is not optimal solution. How do you fix it? I've set up the algorithm to remember passed edges instead of vertexes, but it runs times times longer.

OpenStudy (anonymous):

Found a fixture: don't add all visited vertices to "visited" list. Add only the root node, that is a start node for the next recursion cycle. Thereby visited list will contain only vertices that are visited in current path.

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!