Write recursive binary search algorithm and compare its run time complexity with the non recursive binary search algorithm. Solve the recurrence T() = 2T (/2) + ≥2
= 1 n<2
Answers
Answer:
kskskakskskallsksks is and how much is it possible for the work of chemistry from university is the total best luck for your
recursive binary search algorithm
Step 1: Find the midpoint of the array; this will be the element at arr[size/2]. The midpoint divides the array into two smaller arrays: the lower half of the array consisting of elements 0 to midpoint - 1, and the upper half of the array consisting of elements midpoint to size - 1.
Step 2: Compare key to arr[midpoint] by calling the user function cmp_proc.
Step 3: If the key is a match, return arr[midpoint]; otherwise
Step 4: If the array consists of only one element return NULL, indicating that there is no match; otherwise
Step 5: If the key is less than the value extracted from arr[midpoint] search the lower half of the array by recursively calling search; otherwise
Step 6: Search the upper half of the array by recursively calling search.