Question: for this function: 1 . Modify the function to count the number of operations performed when the function executes in the worst case. See the

for this function:
1. Modify the function to count the number of operations performed when the function executes in the worst case. See the section on counting operations below for more detail.
2. Determine a detailed cost function for the function. This function should be written in the formwnx+yn+zwherew,x,yandzare real numbers andnis a variable referring to the size of the function's input. If necessary, you should adapt this format to include other terms such aslog2(n).
3. Identify all of the barometer operations for the function.
4.Write the O notation running time.
This function is a less than optimal implementation of linear search.
// Desc: Linear search. Reports position if found, else -1
// Post: Elements unchanged
int lsearch(int arr[], unsigned int len, int target){
if (len ==0) return -1;
if (arr[0]== target) return 0;
if (lsearch(arr+1, len-1, target)==-1){
return -1;
} else {
return 1+ lsearch(arr+1, len-1, target);
}
}// lsearch

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!