Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Implement the recursive version of the binary search algorithm inC++. Write the

ID: 3617017 • Letter: I

Question

Implement the recursive version of the binary search algorithm inC++. Write the code to test it out on a sample input.

template<class elemType>
int orderedArrayListType<elemType>::binarySearch(constelemType& item)
{
   int first = 0;
   int last = length - 1;
   int mid;

   bool found = false;

   while(first <= last && !found)
   {
       mid = (first + last) / 2;

       if(list[mid] == item)
           found =true;
       else
           if(list[mid]> item)
           last = mid- 1;
           else
           first =mid + 1;
   }

   if(found)
        return mid;
   else
       return -1;
}//end binarySearch

Explanation / Answer

please rate - thanks #include using namespace std; int binarySearch(int a[],int low,int high,int val); int main() { inti,j,id[10]={5,10,15,20,30,40,50,60,70,80},key=30,max=10,temp; temp= binarySearch(id,0,max,key); cout