text cover

Data Abstraction and Problem Solving with C++

Walls and Mirrors

by Frank M. Carrano

Addison Wesley Logo

c02p098.cpp File Reference


Detailed Description

Binary Search

Date:
29 May 2006
Chapter:
Chapter 2
Page:
Page 98
Version:
5.0

Definition in file c02p098.cpp.

Go to the source code of this file.

Functions

int binarySearch (const int anArray[], int first, int last, int value)


Function Documentation

int binarySearch const int  anArray[],
int  first,
int  last,
int  value
 

Searches the array anArray[first] through anArray[last] for value by using a binary search.

Precondition:
0 <= first, last <= SIZE - 1, where SIZE is the maximum size of the array, and anArray[first] <= anArray[first + 1] <= ... <= anArray[last].
Postcondition:
None.
Parameters:
anArray The array to search.
first The low index to start search from.
last The high index to stop searching at.
value The search key.
Returns:
If value is in anArray, the function returns the index of the array item that equals value; otherwise the function returns -1.

Definition at line 29 of file c02p098.cpp.


Generated on Sun Aug 27 11:05:08 2006 for AWLogo by  doxygen 1.4.6