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

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 00:30, bargasdevon123
To insert a column without using commands in any tabs, a user can -click and then click insert column.
Answers: 3
image
Computers and Technology, 22.06.2019 14:20, capo9972
Cengagenowv2 is a comprehensive online learning tool. using cengagenowv2, you may access all of the following except: 2. each time you log in, cengagenowv2 automatically performs a system check and informs you if your computer does not meet the cengagenowv2 system requirements. 3. which tab/page allows you to easily track your assignment scores, number of submissions, time spent, as well as the ability view assign
Answers: 3
image
Computers and Technology, 22.06.2019 14:30, chaparro0512
Create a pseudocode design to prompt a student for their student id and the titles of the three classes they want to add. the solution should display the student’s id and a total bill. • bill a student using the following rules: o students can only add up to 3 classes at a time.
Answers: 3
image
Computers and Technology, 22.06.2019 14:30, binodkharal2048
Hi plz 11 ! when planning a table, what step comes first: "define the column headers" or "calculate the number of columns/rows"? a. calculate the number of columns/rows b. define the column headers
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 in other subjects: