Question
The economic crisis affected Farids tourism company, so he decided to go to China and work there since he speaks Chinese very well and he
The economic crisis affected Farids tourism company, so he decided to go to China and work there since he speaks Chinese very well and he knows almost all the cities and the various touristic places/attractions. He decided to organize tours between pairs of cities, so he identified a number of cities that tourists like to visit and made a deal with the bus lines. The cost of accompanying a tourist varies between pairs of neighboring cities and in some cases where the trip is to a city that is not so popular, he can make money by having someone take the bus with him! In other words, the cost would be negative between some pairs of cities. After collecting the cost of taking a bus between each pair of adjacent cities, Faird wants to advertise for all his tours. For this he needs to compute the cheapest trip between every pair of cities (not necessarily adjacent pairs). Given a list of adjacent cities along with the cost of a bus between each such pair, you are asked to write a most-efficient algorithm to help Farid with this task. How does your algorithm determine whether Farid can make a huge wealth out of this business (of some unlimited value, without taking money from tourists)? Justify.
The answer was to detect a negative weight cycle using floyd warshall algorithm, since with the presence of a negative cycle that means the tour farid organized would be able to continuously make him money. But I don't understand why do we use floyd warshall instead of bellmand ford algorithm in this case instead.
thank you
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started