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, 24.06.2019 08:30
Formatting rows and columns is similar to cell formatting. in an openoffice calc spreadsheet, you can format data entered into rows and columns with the of the rows and columns options. you can insert rows and columns into, or delete rows and columns from, a spreadsheet. use the insert or delete rows and columns option on the insert tab. alternatively, select the row or column where you want new rows or columns to appear, right-click, and select insert only row or only column options. you can hide or show rows and columns in a spreadsheet. use the hide or show option on the format tab. for example, to hide a row, first select the row, then choose the insert tab, then select the row option, and then select hide. alternatively, you can select the row or columns, right-click, and select the hide or show option. you can adjust the height of rows and width of columns. select row and then select the height option on the format tab. similarly, select column, then select the width option on the format tab. alternatively, you can hold the mouse on the row and column divider, and drag the double arrow to the position. you can also use the autofit option on the table tab to resize rows and columns.
Answers: 1
question
Computers and Technology, 25.06.2019 02:30
Technology has changed communications by replacing or supplementing traditional modes of communication that were primarily
Answers: 2
question
Computers and Technology, 25.06.2019 10:30
Select all that apply. select all functions of an operating system. displays a gui. allows you to multitask. allows you to use the software that you want to use. allows you to edit images. coordinates the interaction of hardware and software. defrags the hard drive. allocates the computer's resources. saves data. retrieves files. keeps confidential documents secure. copies information from one document to another.
Answers: 1
question
Computers and Technology, 25.06.2019 15:30
Is copying and pasting a definition from google but then saying where you got it plagiarism?
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
History, 17.11.2020 19:20
question
Physics, 17.11.2020 19:20
question
History, 17.11.2020 19:20
question
English, 17.11.2020 19:20
question
Mathematics, 17.11.2020 19:20
question
Mathematics, 17.11.2020 19:20
question
Mathematics, 17.11.2020 19:20