ONLY THE WORD EXPLANATION NEEDED NO CODE PLEASE. Also include
PSEUDOCODE - (pointers are not allowed)
You are consulting for an oil company, which is planning a large
pipeline (called the huge pipeline) running horizontally from east to west through
an oil field of n wells. From each well, a spur pipeline is to be connected directly to
the main pipeline along a shortest path (going to either the north or the south).
Suppose that there are n wells, represented by n points p1, p2, ..., pn in the plane.
We are given the x- and y-coordinates of the n wells pi = (xi, yi) for i = 1, 2, 3, .., n.
Note that the wells are not given in any sorted order. Our goal is to pick an optimal
location for the main pipeline (i.e., find the y-coordinate of the main pipeline) such
that the total sum of the lengths of the spur pipelines is minimized. For simplicity,
we assume that no two wells have the same x-coordinate or y-coordinate.
Design an O(n) time algorithm to compute an optimal location for the main
pipeline.