CS 221
Advanced Programming

Monday, February 23, 2009

Search and Recursion

Today we implemented linear search, binary search, generic linear search, and generic binary search in class. We created a junit test class to test each search algorithm and show they were working properly. The trickiest part was implementing a generic binary search since we need to compare an arbitrary key to an arbitrary generic object. We looked at two ways to do this, multiple generics or use of Object for the key. We chose to use an Object for the key and implement the comparable interface on the objects in the search space. We changed the generic search class to require a generic object that implements the Comparable interface by using the extends keyword on the generic definition.

We ran out of time to discuss recursion, so we will begin covering that on Wednesday.