Write a function named shortpath which has two input


Question 1: Write a function named 'short_path' which has two input parameters {M, N} and one output parameter T.

We shall assume that each element of M should be a number in the range [0,N] and that M is a square matrix.

Question 2: Each element M(i,j) represents the cost of travelling from location i to location j.

Use an if-end statement to check whether for all k, M(k,k) = 0. If it is not, display an error message of your choice, set T to 1 and terminate the function (in other words, the cost to travel from i to i should be zero, hint: use 'return').

Question 3: Assuming the condition in part (b) has been satisfied, find the triple of locations {i, j ,k} with the shortest distance between them.

That is, the value V = M(i,j) + M(j,k) should be the minimum among all triples {i,j,k} one could try. Set T to the triple of indices you found.

 

Request for Solution File

Ask an Expert for Answer!!
C/C++ Programming: Write a function named shortpath which has two input
Reference No:- TGS0955507

Expected delivery within 24 Hours