Saint Louis University |
Computer Science 314
|
Dept. of Math & Computer Science |
Topic: Divide and Conquer
Related Reading: Ch. 5
Due:
Monday, 27 March 2006, 12:00 noon
Please make sure you adhere to the policies on academic integrity.
See "Solved Exercises" in Chapter 5 of text
Exercise 1 of Chapter 5 (p. 246)
Exercise 3 of Chapter 5 (p. 247)
You are to implement both the O(n2) brute-force and the O(n log n) divide and conquer algorithm for finding the closest pair of points in two dimensions (you may use the programming language of your choice).
More details to follow soon, as well as some sample data sets, and some required experiments regarding timing. For now, let me just iron out a standard file format. The first line is an integer, which specifies the number of points in the set. Then each additional line specifies a single point, given three fields of form:
xval yval stringTagwhere xval and yval are integers and the remainder of the line (if any) serves as the stringTag. Here is a simple sample file:
5 8763 4188 Chicago 9038 3875 St. Louis 9458 3912 Kansas City 8628 3973 Indianapolis 9365 4153 Des Moines
We have created several random data sets which you can use for testing. Also, please report the running times which your program achieves on each of the data sets, for both the efficient and brute force solutions. (of course when the brute force becomes unreasonably slow, you do not need to wait for it to complete).
In Exercise 3 of the text, you developed an O(n log n) time algorithm for finding an equivalent cluster of cards.
It is actually possible to solve this problem in O(n) worst case time. Develop and analyze such an algorithm.