Write a function to perform a binary search on a Sorted Array.
Click for Solution
  • A int binary_search(int []a, int l, int h,int el)
    {
    int mid=(l+h)/2;
    if(el==a[mid])
    returna[mid];
    elseif(el<a[mid])
    return binary_search(a,l,mid-1,el);
    else
    return binary_search(a,mid+1,h,el);
    }

[Insert Code]