← All problemsFree · Python · 55 min

Algorithm design / guarantees under an adversary

The Radio Masts

Cover every village with the fewest radio masts. Find where greedy builds twice as many as needed, then write a weighted greedy that returns a lower bound proving it is within H(k) of the best.

0 / 3 graded parts passSaved in this browser · loading saved work…
Jump to your work ↓

A county wants radio coverage in its ten villages, numbered 1 to 10. It has six possible masts, and each would cover the villages linked to it in the figure. It wants to cover every village with as few masts as possible. This is set cover, and it is NP-hard.

mast 1mast 2mast 3mast 4mast 5mast 612345678910mastsvillages
Each line joins a mast to a village it would cover.

The obvious method is greedy: build the mast that covers the most villages not yet covered, and repeat until every village is covered. This problem asks how bad greedy can be, and then asks for a greedy answer that carries a proof of how good it is.

The same six masts as a list:

mast villages it covers
1 7, 10
2 2, 3, 8, 10
3 4, 5, 6, 9
4 3, 5, 6, 8, 9
5 3, 7, 9, 10
6 1, 7, 8, 10

Background: Approximation Algorithms.

easy · Part A

Ten villages

What is the fewest masts that cover all ten villages? How many does greedy build? Enter the fewest.

Explore in the sandbox

Experiment here, then copy a rule into the editor and test its guarantees.