Question: Consider the following recursive algorithm: ALGORITHM Secret ( A , lowIdx, highIdx ) / / Input: / / - An array A [ 1 .

Consider the following recursive algorithm:
ALGORITHM Secret (A, lowIdx, highIdx)
// Input:
//- An array A[1..n] of integer numbers
//- integers lowIdx, highIdx
// Variables:
//- integers midIdx, temp1, temp2
if lowIdx == highIdx
return lowIdx
else
midIdx =(lowIdx+highIdx)/2
temp1 Secret (A, lowIdx, midIdx)
temp2 Secret (A, midIdx+1, highIdx)
if A[temp1]>= A[temp2]
return temp1
else
return temp2
a)[10 points] What does this algorithm return?
b)[20 points] Set up a recurrence relation for the algorithms running time and solve it.

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!