int example(int arr[], int 1, int r, int 1, x); x); if (r>= 1) { } } int mid=1+ (r-1)/2; if (arr[mid] =x) return mid; if (arr[mid] >x) return example(arr, 1, mid - return example(arr, mid + 1, r, return -1; 1. What is the name of this algorithm? 2. What is special for the input array? 3. Is this algorithm a recursive algorithm or not? Why or why not? 4. What is the recurrence formula for this algorithm? 5. How to solve the recurrence formula using e.g. master theorem?

icon
Related questions
Question
100%
Java source code reading- Please read the java source code on the left and answer the questions on the right
int example(int arr[], int 1, int r, int
x)
{
if (r>= 1) {
1, x);
}
}
int mid=1+ (r - 1)/2;
if (arr[mid]=x)
return mid;
if (arr[mid] > x)
return example(arr, 1, mid-
return example (arr, mid + 1, r,
return -1;
1. What is the name of this algorithm?
2. What is special for the input array?
3. Is this algorithm a recursive
algorithm or not? Why or why not?
4. What is the recurrence formula for
this algorithm?
5. How to solve the recurrence formula
using e.g. master theorem?
Transcribed Image Text:int example(int arr[], int 1, int r, int x) { if (r>= 1) { 1, x); } } int mid=1+ (r - 1)/2; if (arr[mid]=x) return mid; if (arr[mid] > x) return example(arr, 1, mid- return example (arr, mid + 1, r, return -1; 1. What is the name of this algorithm? 2. What is special for the input array? 3. Is this algorithm a recursive algorithm or not? Why or why not? 4. What is the recurrence formula for this algorithm? 5. How to solve the recurrence formula using e.g. master theorem?
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps

Blurred answer