Diamond6748 Diamond6748
  • 15-12-2022
  • Computers and Technology
contestada

Given this function, what is the big O time complexity?
int search(int arr[], int l, int r, int num) {
if (l <= r) {
int mid = (l + r)/2;
if (arr[mid] == num)
return mid ;
if (arr[mid] > num)
return search(arr, l, mid-1, num);
if (arr[mid] < num)
return search(arr, mid+1, r, num);
}
return -1;
}
a.
O(n2)
b.
O(1)
c.
O(logn)
d.
O(n)

Respuesta :

Otras preguntas

What is the speed of a bobsled whose distance-time graph indicates that it traveled 112m in 29s?
PLS HELP,ASAP I NEED ANSWER ASAP
Liam had a number of chocolates in his pocket. he decided to give most of them away before they melted. so he gave two-thirds to Lucy, then one-fifth of the rem
In the Adventure of Ulysses who is Ino? Describe her and explain how and why she helps Ulysses.
One the outline map of India, mark and label the following with appropriate symbols: (a) The highest peak of the Aravali hills. (b) Southernmost tip of main lan
The middle colonies thrived because
What happened on Lexington Green on April 19, 1775?
Please help me find the answer
Who were the first two countries that fought in WW1? Also when did the Americans joined in and why?
How can atoms make up all the substances around you