Question

1) Given a weighted (positive weights) undirected graph G and a vertex A find the cost...

1) Given a weighted (positive weights) undirected graph G and a vertex A find the cost of the cheapest path that visits all the vertices. It doesn't need to return to A. It can visit vertices multiple times. need  the algorithm and pseudocode for this approach.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

ALGORITHM

  • Start from vertex A
  • Take a table with column names as vertices except A. Take first column as vertices.
  • Fill the first cell with A and now write the distances from A to all other vertices if any are connected and write A as suffix otherwise put -
  • Now take the least weighted vertex and cross off the cells in that column.
  • From there consider the neighboring edges and update the weights with accumulated weight from the starting.
  • Continue this till all vertices are visited.
  • By the end we will have the distance to the vertices and the parent vertex as suffix.

-- Please up vote or comment if you have any doubts. Happy Learning!

Add a comment
Know the answer?
Add Answer to:
1) Given a weighted (positive weights) undirected graph G and a vertex A find the cost...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT