Error Correction Question

Correct following program.


Function bsearch is the binary search function:
it searches x in the acendary ordered array, from a[left] to a[right].
If not found, it returns -1.



int bsearch(int a[], int left, int right, int x)
{
   int mid;

   if (left == right)    return -1;
   mid = ( right - left ) / 2;
   if (a[mid] == x)    
      return mid;
   else if (a[left] < a[mid])   
      return bsearch(a, left, mid, x);
   else 
      return bsearch(a, mid, right, x);
}

Result