CPSC 212
(Data Structures and Algorithms)

Assignment 1

Objectives:
To create a simple C++ 2D point class, implement STL sort, average.

Due date:
09/05/06

What to hand in:
Code "tarball" (e.g., asg1.tar.gz) including:
  1. README file containing assignment and solution descriptions, e.g., program design, description of algorithm, etc., if appropriate.
  2. INSTALL file containing any specific compliation quirks peculiar to your program, e.g.,
    Compilation: make -f Makefile.tniop.
  3. USAGE file containing any specific usage quirks peculiar to your program, e.g.,
    Usage: ./tniop < points.in where ./tniop is the executable and points.in is the input.
  4. src/ directory with source code.

Description:
  1. Implement a 2D Point class, with functionality suggested in the point.h interface.
    (You are free to rewrite the class interface and declare your own Point class, so long as it satisfies the required funcionality requirements.)

  2. Your class must be able to handle I/O and object comparison via functors, as suggested in the tniop.cpp driver.

  3. Provide code in the driver to compute the centroid of the found in the points.in input file.

  4. Sample output (sans centroid) can be found here: points.out.

  5. (Bonus) Write the centroid code ``on the fly'', i.e., in one loop instead of one summation loop followed by division by n
    Hint: the math for this is: mi = (i/(i+1)) mi + (1/(i+1)) xi