Question: Question 6 Search for an element: Given an array of numbers and a value v, the goal is to find the position of an element

Question 6 Search for an element: Given an array of numbers and a value v, the goal is to find the position of an element in the array that has value v or return -1 if such element does not exist. Design a divide-and-conquer algorithm to solve the problem (you can assume that n= 2k for some k > 1). (a) Indicate clearly what actions are to be performed in the Divide, Conquer and the Combine steps of your algorithm. (b) Based on your answer to Part (a), write the pseudo code for your algorithm. (c) Let T(n) denote the running time of your algorithm when the array has n elements. Specify a recurrence for T(n), explaining how you arrived at the recurrence. (d) Solve the recurrence to obtain the running time of the algorithm. (e) What if the array was sorted? Can you devise a faster divide and conquer? Question 6 Search for an element: Given an array of numbers and a value v, the goal is to find the position of an element in the array that has value v or return -1 if such element does not exist. Design a divide-and-conquer algorithm to solve the problem (you can assume that n= 2k for some k > 1). (a) Indicate clearly what actions are to be performed in the Divide, Conquer and the Combine steps of your algorithm. (b) Based on your answer to Part (a), write the pseudo code for your algorithm. (c) Let T(n) denote the running time of your algorithm when the array has n elements. Specify a recurrence for T(n), explaining how you arrived at the recurrence. (d) Solve the recurrence to obtain the running time of the algorithm. (e) What if the array was sorted? Can you devise a faster divide and conquer
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
