subject

The streets of a certain city form a very regular square grid. Some streets run north-south and others run east-west. Every intersection can be described by a pair of integer coordinates (i, j) in an obvious way. Because of the grid geometry, the distance you have to walk to get from one intersection (i1,j1) to another intersection (i2, j2) is |i1 − i2| + |j1 − j2|. For simplicity let us assume that the address of each resident of the city is some intersection point (i, j). The city wants to locate a hospital at some intersection in such a way as to minimize the total distance traveled by all residents to get to the hospital. Your task is to design an algorithm that takes as input a list of addresses (repeats allowed) of all n residents in the city , and return the location of the hospital that is optimal with respect to the city’s criterion above. Design such an algorithm that runs in O(n) time.

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 06:30
Plz 40 points what are raster vectors? a bitmap image a vector file a type of printing press a small projector
Answers: 1
question
Computers and Technology, 22.06.2019 20:00
What is used to analyze and summarize your data without graphical support
Answers: 1
question
Computers and Technology, 23.06.2019 00:00
What season was better from fortnite?
Answers: 2
question
Computers and Technology, 23.06.2019 15:00
Barbara is interested in pursuing a career in the science and math pathway. which qualifications will her reach that goal? a.an advanced knowledge of physics and math b.an advanced knowledge of engineering and math c. an advanced knowledge of physics and robotics an d. advanced knowledge of machinery and math
Answers: 1
You know the right answer?
The streets of a certain city form a very regular square grid. Some streets run north-south and othe...
Questions
question
Mathematics, 26.01.2021 06:10
question
Spanish, 26.01.2021 06:10
question
Mathematics, 26.01.2021 06:10
question
Mathematics, 26.01.2021 06:10
question
Chemistry, 26.01.2021 06:10
Questions on the website: 13722361