Write a iterative and recursive versions of binary search


Question- Write a iterative and recursive versions of binary search and compare their run times using the array a[i]=i, i=0,...,n-1 and the subsequent test method:

for(i=0; i

if(a[i] != a[binary_search(... a[i] ...)]) cout << "ERROR\n";

I already have an iterative function and a recursive function that are binary searches. I do not know how to do the second part which is to compare their run times using an array and the given test method.

 

Request for Solution File

Ask an Expert for Answer!!
C/C++ Programming: Write a iterative and recursive versions of binary search
Reference No:- TGS0966321

Expected delivery within 24 Hours