Post BY: Hanan Mannan
Linear search of an array
===================
int linearSearch( const int array[], int key, int size )
{
int n;
for ( n = 0; n < size; ++n ) {
if ( array[ n ] == key ) {
return n;
}
}
return -1;
}
Linear search of an array
===================
int linearSearch( const int array[], int key, int size )
{
int n;
for ( n = 0; n < size; ++n ) {
if ( array[ n ] == key ) {
return n;
}
}
return -1;
}
0 comments:
Post a Comment