vendredi 15 juillet 2016

JAVA/Programming Algorithm

please help me to solve this issue, I was thinking to use recursive algorithm to solve this, but cannot come out with a solution.

Write a program to find the cheapest path from one vertex to another in a directed acyclic graph, given data in the format (starting vertex, ending vertex, cost). Assume all costs are positive.

Using the data:
• A → B: 1
• B → C: 1
• A → C: 2.5
• A → D: 0.4
• D → B: 0.3

When finding the cheapest path from A to C, the expected answer is A=>D=>B=>C, cost 1.7.

Please write the solution in Java including the test case demonstrating the correctness of your solution.

Aucun commentaire:

Enregistrer un commentaire