Question: State the recursive equation for the worst case running time of this pseudocode: There is no need to actually solve this equation. ****code description find-in-halves

State the recursive equation for the worst case running time of this pseudocode:

State the recursive equation for the worst case running time of this

There is no need to actually solve this equation.

****code description

find-in-halves looks for k in the middle cell mid of the array A[i . . . j]. If k = A[mid], it returns the index, mid, for this cell. Otherwise it compares k with the value of the middle cell, A[mid]. If k is smaller, it makes a recursive call looking for k in the first half of the array A[i..(mid 1)]. If k is larger, make a recursive call looking for k in the second half of the array A[(mid+ 1)..j]. If k is not in A[i . . . j], find-in-halves, it returns 1. The initial call is find-in-halves(A[1 . . . n]).

******code description

function find_in_halves (A[],k,lo=1,hi=n){ mid =(hi+10)/2 if (k==A[ midd ) return mid if (lo ==hi) return 1 else if (k

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 Databases Questions!