02/21/00
COM1100 Winter2000 Yuhong Yin
9
Binary search algorithm
n// function prototype
nint binarySearch(int list[], int size, int key);
n 
n// function definition
n// this function returns the location of  key in the list
n// -1 is returned if the value is not found
nint binarySearch(int list[], int size, int key) {
n int left, right, middle;
n 
n left = 0;
n right = size -1;
n (refer to next slide)
n