Zebra0.com

cpp searchA Binary Search

A Binary Search

The list of names below is sorted into alphabetical order. When we search an ordered list, we can write a much more efficient search. For an ordered list, you can use a binary search.

index names years
0Amy2010
1 Bill1985
2 Debbie1976
3 Ian1987
4 Jay1974
5 Josh2003
6 Lin2009
7 Mark1979
8 Paul2001

We will use the same program that read in the names from a file, but instead of a sequential search, we will use a binary search.