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

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 21:10
Dameas communication challenge is due to which factor
Answers: 2
question
Computers and Technology, 23.06.2019 15:10
What role did women fill during world war ii?
Answers: 1
question
Computers and Technology, 23.06.2019 15:30
Brian wants to conduct an online search with a certain phrase. he intends to use the words books that belong to the 1800s in his search. how should he use the word that in his search?
Answers: 1
question
Computers and Technology, 23.06.2019 17:00
The more powerful, 60 volt cables and the main power shut off on an hev are both colored orange
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
question
Mathematics, 08.05.2021 01:00
question
History, 08.05.2021 01:00
Questions on the website: 13722359