Binary Search

Recursion can be used to implement binary search, which is a fast way of locating something in a list. This is done here in a general way using the Comparable interface (no generics). Binary search successively divides a list in half, throwing away the half that cannot contain the thing being looked for. It terminates either with the object being sought, or with the empty list.

A testing program is also included. It generates an array of random Integer objects, sorts it, then searches through the list for a given target.