Recherche binaire basée sur une fonction recursive

Author:


Download


long *rechercheBinaire( long val, long tab[ ], int n )
{
  int m = n/2;
  if ( n <= 0 )          return NULL;
  if ( val == tab[m] ) return tab + m;
  if ( val <  tab[m] )
	  return rechercheBinaire( val, tab, m );
  else
	  return rechercheBinaire( val, tab+m+1, n-m-1 );
}

Leave a Reply

Your email address will not be published. Required fields are marked *