Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please use c++ to do the following code The objective of this project is to (1) correctly implement the exhaustive approaches to solving TSP (2)

Please use c++ to do the following code

The objective of this project is to (1) correctly implement the exhaustive approaches to solving TSP (2) compare these with their asymptotic complexities. Your program should assume the input file is formatted as follows: 4 0 0 10 0 0 5 10 5 The first line contains n, the number of points. Each of the next n lines contains the (x, y) coordinates of the n points. Assume all coordinates are integers. Your output should report the length of the TSP tour to three places of decimal. For consistency with our solutions, your tour should start at the first point listed in the input. [In the example this would be (0, 0).] The output would be: 30.000 This would correspond to the following NN TSP tour (0,0) (0,5) (10,5) (10,0) (0,0). The second approach is the exhaustive algorithm that we discussed in class that tries all permutations. Pseudocode may be found on Page 8 of the text. This approach is guaranteed to find an optimal solution, but is very slow. You may use a library, consult the internet or any other reliable source to find code or an algorithm to generate all permutations.

Pseudocode:

OptimalTSP(P)

d =

For each of the n! permutations Pi of point set P

If (cost(Pi) d) then d = cost(Pi) and

Pmin = Pi

Return Pmin

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Principles Programming And Performance

Authors: Patrick O'Neil, Elizabeth O'Neil

2nd Edition

1558605800, 978-1558605800

More Books

Students also viewed these Databases questions