Assignments | Course Home | Schedule & Lecture Notes

Saint Louis University

Computer Science 314
Algorithms

Michael Goldwasser

Spring 2006

Dept. of Math & Computer Science

Homework Assignment 05

Divide and Conquer

Contents:


Overview

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.


Practice Problems


Problems to be Submitted (40 points)

  1. (10 points)

    Exercise 1 of Chapter 5 (p. 246)

  2. (10 points)

    Exercise 3 of Chapter 5 (p. 247)

  3. (20 points)

    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 stringTag
          
    where 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).


Extra Credit

  1. (4 points)

    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.


Michael Goldwasser
CSCI 314, Spring 2006
Last modified: Friday, 24 March 2006
Assignments | Course Home | Schedule & Lecture Notes