subject

There are n buildings in campus. david doesn’t have a good memory, so he wants to choose n - 1 roads that, from any building in the campus, he can get to any building he wants. however, david doesn’t want to walk too much, so he also wants total length of all roads to be minimum. your task is to david to find those n - 1 roads. for the simplicity of the problem, instead of using building’s name, we will use the building’s number, so there are n buildings from 0 to n - 1. in map. java, implement the following method:
int mindistance(int[][] dists): takes an input of a 2-d integers array where dists[i][j]
is the distance of a single road from building i to building j (note that dists[i][i] is always 0
and dists[i][j] = dists[j][i] > 0 when i ! = j). returns the minimum total distance of n - 1
roads. for example, giving this 2-d array:
0 1 2 10
1 0 3 4
2 3 0 3
10 4 3 0
your method should return 6 because the roads david should choose are 0 - 1; 0 - 2; 2 - 3.
also include the main method in map. java to test at least 3 scenarios with n > 4

ansver
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 02:20, eagles2286
The reset circuit used on the four 3-bit counters analyzed in this activity reset the counts to zero (000). it makes sense for the up-counters to start at zero (000), but the down-counters should start at seven (111). what would you need to change so that the 3-bit binary down counter with j/k flip-flops you just created would reset to seven (111)?
Answers: 1
image
Computers and Technology, 24.06.2019 20:10, austinwst3
Approximately what portion of global employers tends to use social media websites to hire new employees?
Answers: 1
image
Computers and Technology, 25.06.2019 03:30, adrianVocke5685
Kou converged his word document to a powerpoint document. when he received the powerpoint, he was missing material. which most likely explains why the material was missing? a it did not have a proper heading b he incorrectly copied and pasted it c he did not save his document properly d there was not enough space in powerpoint
Answers: 1
image
Computers and Technology, 25.06.2019 07:30, sugar75
The can be used to paste text in any order.
Answers: 1
You know the right answer?
There are n buildings in campus. david doesn’t have a good memory, so he wants to choose n - 1 roads...

Questions in other subjects:

Konu
Mathematics, 11.09.2021 06:10