CS 213(M) Data Structures and Algorithms

Syllabus:

Review of recursion. Techniques for proving
correctness of programs. Analysis of time taken by a program.
Algorithms for sorting. Quicksort with analysis. Sorting lower bounds.
Dynamic memory management and class design in C++. Heaps, balanced search trees. Implementation of vector class from
C++. Implementation of iterators.
Representing graphs. Algorithms based on depth first and breadth
first search. Shortest path algorithms.

General remarks

The emphasis in the course is as much on reasoning about
programs as writing programs. You may get fewer marks if you are
not able to explain your programs, and in general if you do not
write clearly and neatly.

Assignment 2: Suppose you have n balls of unit mass and radius
positioned on a straight line at specified positions. They are free
to move along the line and their initial velocities are also given.
Assume there is no friction and that collisions are elastic,
i.e. when balls collide their velocities just get exchanged. As you
can see, there will be some number of collisions after which the
balls will simply escape to infinity on either side of the line.
You are to write a program which takes the initial positions and
velocities and prints the position and velocities of the balls at
the time just after the last collision. Your code should include a binary heap
-- it will help in speeding up execution.