Notes for High Speed Internet problem

Notes for the High Speed Internet problem.

Material Developed by: Atri Rudra

Proof (of Correctness) Idea

First note that the algorithm above places $\left\lceil \frac{d_{\max}}{100}\right\rceil$ many cell towers.

To complete the proof, we claim that any valid placement of towers must place at least $\left\lceil \frac{d_{\max}}{100}\right\rceil$ cell towers. For the sake of contradiction assume that we are able to come up with a valid placement with \[\le \left\lceil \frac{d_{\max}}{100}\right\rceil -1 < \frac{d_{\max}}{100}\] cell towers. Since each cell tower can cover $100$ miles, this means that the total number of miles covered will be \[<100\cdot \left(\frac{d_{\max}}{100}\right) = d_{\max},\] which means at least $1$ mile from the first house and the last house does not have cell coverage, which means that our placement was not valid.

Runtime analysis

We will assume the following, which you need to prove on your own:

Exercise 1

\[d_{\max}\le 99n.\]

This implies that the while runs for at most $99n/100\le n$ times. Each iteration takes $O(1)$ time: so overall the loop takes $O(n)$ time. Since computing $d_{\max}$ takes $O(n)$ time, the overall runtime is $O(n)$, as desired.

Part (b)

We would like to point out two things:

  1. The algorithm above for part (a) does not work for part (b). The basic idea is that the algorithm from part (a) can place a cell tower at a mile where there is no house but for part (b) the cell towers have to be at a house. See the sample input/output above for a concrete example.
  2. Think how you could modify the algorithm for part (a) could be modified to handle the extra restriction that the cell towers have to placed next to a house.

    Hint

    Think of a greedy way to decide on which houses to pick for cell tower installation. It might help to forget about the scheduling algorithms we have seen in class and just think of a greedy algorithm from "scratch." Then try to analyze the algorithm using similar arguments to one we have seen in class.

    Note

    The proof idea for part (a) does not work for part (b): you are encouraged to use one of the proof techniques we have seen in class to prove correctness of a greedy algorithm.