Question: please explain and write clearly 1. Consider the following recursive function: //input is an array of integers, first element and last element int mystery (int
1. Consider the following recursive function: //input is an array of integers, first element and last element int mystery (int arr[], int begin, int end) if (begin >= end) { return 1; if (arr [begin] == arr[end]) { return mystery (arr, begin + 1, end - 1); else { return 0; a. What does a final result of 1 say about the array? That is, what is this function computing? b. Write a recurrence relation that represents the time complexity of the function. c. Solve the recurrence relation and state the complexity of the function in notation. 2. Develop a divide and conquer algorithm that will find the number of l's in a sorted binary array. That is, if the list is [0, 0, 0, 1, 1, 1, 1] the answer should be 4. 3. Find the recurrence relation for problem #2 and state the asymptotic complexity of your solution
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
