Figure 3:
An Algorithm for Phase (a)