Question: Given the following pseudocode, write the recurrence relation that describes the time complexity of the algorithm. Then, draw a recursion tree for the recurrence relation

Given the following pseudocode, write the recurrence relation that describes the time complexity of the algorithm. Then, draw a recursion tree for the recurrence relation and solve the recurrence to find the time complexity.
def search_algorithm(arr, low, high, x):
if high >= low:
mid =(high + low)//2 if arr[mid]== x: return mid
elif arr[mid]> x:
return search_algorithm(arr, low, mid -1, x) else:
return search_algorithm(arr, mid +1, high, x) else: return -1

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!