CS 1101.py Computer Science I
Spring 2016

Computer Science Department
The Morrissey College of Arts and Sciences
Boston College

About Staff Textbook Grading Schedule Canvas
Piazza Library Resources Labs GitHub Problem Sets
Problem Set 5: Best Candidate Algorithm

Assigned: Sunday February 21, 2016
Due: Sunday February 28, 2016
Points: 10 Points

In class we've briefly discussed the problem of randomly distributing points in the xy-plane. One can use the Random.float function to compute a random x-coordinate and a random y-coordinate. But the result will often have too many points that are clumped together with other areas being completely free of points.

The best candidate algorithm is an iterative algorithm that maintains a list of random points [p1, ..., pk]. In each cycle through the algorithm, a set of candidate points [c1, ..., cj] are generated, exactly one of these candidates will be selected join the list of random points. In particular, for each candidate ci, the nearest neighbor in [p1, ..., pk] is found. The candidate with the largest distance to it's nearest neighbor is the best, it joins the list of random points and the other candidates are discarded.

Implement the best candidate algorithm as described above. Your implementation should render the set of generated as small circles on the xy-plane provided by the stddraw library.

Created on 01-19-2016 23:10.