In this chapter, we cover searching and sorting. In Chapter 10, we presented a case
study of maintaining an address book and described a basic searching method to
locate a student, given his or her name. In this chapter, we will present a better searching
algorithm called binary search. To apply binary search, an array must be sorted.
Sorting is a technique to arrange elements in some order, and it is one of the fundamental
operations we study in computer science. We will cover basic sorting algorithms
in this chapter and an efficient recursive sorting algorithm in Chapter 15.We
will use an array of integers to illustrate searching and sorting algorithms, but all the
techniques we present here are equally applicable to any array of objects as well as
primitive data types. In the sample development (Section 11.4), we will extend the
AddressBook class by adding the capability of sorting an array of Person objects.
To learn more about the book this website supports, please visit its Information Center.