Skip to content

A salesman wants to go to five different cities and sell som

Do you have a similar question? Our professional writers have done a similar paper in past. Give Us your instructions and wait for a professional assignment!        

A salesman wants to go to five different cities and sell some products.The location of the cities are listed in the following table.City # X_location Y_locationCity 1 1 1City 2 1 3City 3 4 1City 4 5 3City 5 3 6City 6 5 5The distance between two cities is defined as the Euclidean distance. That is:?istance = sqrt( (x1 – x2)^2 + (y1 – y2)^2 )For example, the distance between cities 1 and 2 will be:Distance = sqrt( (1 – 1)^2 + (1 – 3)^2 ) = sqrt( 4 ) = 2The purpose: The salesman starts his journey from city 1. He then has 5 remaining options for the next city (city 2, city 3, city 4, city 5, city 6). If he chooses city 3 as the next destination, then he will have 4 remaining options (city 2, city 4, city 5, city 6).?e wants to travel all the cities and then come back to the start location (City 1). For example, out of many possible choices, a sample possible path can be:City 1 => City 3 => City 4 => City 2 => City 6 => City 5 => City 1Each path will have a total distance. We want to help the salesman by finding the shortest path (best order of cities to visit (visit all of them once) starting from city 1).Steps:Step 1 [3 points]: Create a class City with x and y as the class variables. The constructor with argument will get x and y and will initialize the city. Add a member function getDistanceFrom() to the class that gets a city as the input and finds the distance between the two cities.?city1.getDistanceFrom(city2)?ill be distance between city 1 and 2.Step 2 [3 points]: Create 6 city objects and initialize their location (x and y) using the above table. Then put all of the 6 cities in a vector.Step 3 [7 points]: Create a two dimensional array or vector DistanceMatrix of size 6 * 6 and initialize it such that DistanceMatrix [i,j] is the distance between city_i and city_j.?rint the DistanceMatrix and show the distance among all cities.Step 4 [12 points]: Assume that the salesman starts from the city 1 and would like to visit all the other cities and then come back to the start city (city 1). Search all the possible paths salesman can travel and find the optimal path (order of cities to visit) that leads to the minimum total travel distance. Display the found optimal path (order of cities to travel) in your sample run.Computer ScienceEngineering & TechnologyC++ ProgrammingCSC 252

Get a plagiarism-free order today   we guarantee confidentiality and a professional paper and we will meet the deadline.    

Leave a Reply

Order a plagiarism free paper today. Get 20% off your first order!

X