int BinarySearch(int a[], const int &x, int lef, int rig)
{
if(lef <= rig)
{
int mid = (lef + rig) /2;
if(x == a[mid])
return mid;
else if(x > a[mid])
return BinarySearch(a, x, mid+1, rig);
else
return BinarySearch(a, x, lef, mid-1);
}
}
int BinarySearch(int a[], const int &x, int lef, int rig)
{
if(lef <= rig)
{
int mid = (lef + rig) /2;
if(x == a[mid])
return mid;
else if(x > a[mid])
return BinarySearch(a, x, mid+1, rig);
else
return BinarySearch(a, x, lef, mid-1);
}
}