Represent the real numbers

Assignment Help C/C++ Programming
Reference no: EM13937065

Assume you are given a set of N < 10 cities with pairwise distances between them represented as real numbers. A traveler starts from city #1 and wants to visit all other cities just once and return back to the origin. Assume there is a direct airline between any two of these N cities. Your task is to design a C++ program that will find an optimal route for the traveler. That is, the program should return a route of minimum total length. Assuming that the traveler always starts from city 1 the output of the program for N = 4 should be of the form
1 -> 2 -> 4 -> 3 : 226.6

where the last number is the minimum total distance.

Create a file dist.dat for storing the pairwise distances represented as an NxN table of numbers. The number at the intersection of the i-th column and j-th row is the distance from city i to city j. So the table is symmetric; that is, the number at the intersection of row i and column j is the same as the one at the intersection of column i and row j. Note that the number N of cities is not presented explicitly in the file, your program has to figure it out. Your program should read the data from the file by using the input redirection.

Example of such file for N = 4:

56.78 11.80 79.34 78.23
11.80 16.26 65.23 45.19
79.34 65.23 63.29 90.27
78.23 45.19 90.27 87.35

Create your own file for at least 7 cities.
Your program should work for any N in the range [3..10]

Reference no: EM13937065

Questions Cloud

Exploit be demonstrated safely in-class : Task: You are required to create and deliver a presentation providing an analysis of an existing software exploit (therefore you are not required to craft a new, unknown exploit yourself).
Ethical philosophy of an organisation : The ethical philosophy of an organisation is usually embedded into the culture of the organisation by its leaders. Describe what ‘leadership by example' is and how it helps create an ethical culture.
What is the hormone that is tested for in pregnancy : Pregnancy can be detected several days post-implantation, based on a hormone level test. What is the hormone that is tested for in pregnancy, and what is its role? How is the test administered, and who may perform it?
Future career in health care : Consider your future career in health care. What opportunities will you have to promote health enhancing behaviors and discourage health compromising behaviors?
Represent the real numbers : Assume you are given a set of N
Socioeconomic status affects health : How race, gender and socioeconomic status affects health
Explain the importance of sexual reproduction : As you can see in these three life cycles, those of higher organisms tend to emphasize the diploid stages more than the haploid stages. Explain why there has been a trend toward diploidy among higher organisms; what are the advantages of being dip..
What are the mix of product you wish to concentrate on : 1. What are the mix of product you wish to concentrate on? -how is your product similar/different to that of competitors
Evaluate its employees four times a year at the end of year : The data will be validated and saved to an output file,"datainput" . this program will use five arrays to grater manupliate and store the data.

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Write a program that asks user to enter

Write a program that asks user to enter the size of the matrix (rows and column) then, it asks the user to enter the elements of two matrices and finally it adds two matrix and displays the result in C language.

  Write a program that will convert us dollar amounts

Write a program that will convert US dollar amounts to Canadian dollar (1 CND = 0.92 USD). Format your currency amounts in two decimal places and trailing zeros.

  Null pointer problem

What is the only thing that you should ever do with the NULL pointer? In the following declaration, explain what type p is, and describe how it might be used.

  Implementation of the recursive algorithm

Develop an iterative method having the same functionality as the recursive nextPermutation method - Create a class SortingFunctions.

  Write a c function called bspline

Write a C function called Bspline that takes as input a single double precision argument called x. The function returns a double precision value y determined as given

  Describe what an attribute or data member of a class

Analyze a basic set of requirements for a problem - Describe what an attribute or data member of a class - Distinguish between pass-by-value and pass-by-reference

  Print each employee''s identification number

1) in a program you need to store the identification numbers of 10 employees (as ints) and their weekly gross pay (as doubles) A) Define two arrays that may be used in parallel to store the 10 employee indentificcation numbers and gross pay amounts B..

  Compiling in dev c++ program

I will post my code. Just so you know that before implementing the template the program worked fine but I believe the issue is in the declaration of the friend functions somehow.

  Discuss the different c++ loops and their characteristics

Discuss the different C++ loops, their characteristics

  Method celsius return celsius equivalent of fahrenheit

Method Celsius return the Celsius equivalent of a Fahrenheit temperature,using the calculation Celsius = 5.0/9.0*(Fahrenheit -32); method Fahrenheit returns the Fahrenheit equivalent of a Celsius temperature, using the calculation  Fahrenheit = 9.0/5..

  Complexity of quick sort algorithm

Write a c program to experimentally compare the O() complexities of the provided quick sort algorithm

  Determines whether a given number is a perfect square

Write and test the following function that determines whether a given number is a perfect squarebool IsSquare(int);

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd