Below is a binary search function.
int search(int a[], int v, int left, int right)
{
while (right >= left)
{
int m = (left + right)/2;
if (v == a[m])
return m;
if (v < a[m])
right = m - 1;
else left = m + 1;
}
return -1;
}
How do I determine the Big-O notation for this function?
Is this search function O(n) since the while loop is dependent on the value of left?