Question: Input: An array A=(Q1, Q2, ..., ..) of n numbers, indices l and r, a value u. 1. For i=ltor 2. If A[i] = v
Input: An array A=(Q1, Q2, ..., ..) of n numbers, indices l and r, a value u. 1. For i=ltor 2. If A[i] = v 3. Then return i. 4. return -1. a. (4 pts) Show the iterations step-by-step of the pseudocode for the in- stance A= (6, 8, 10, 15), 1 = 1, r = 4, v = 12. b. (1 pts) Describe the inputs, outputs and the computational problem that the pseudocode solves. c. (1 pts) What is the computational complexity of the pseudocode? Is it an efficient algorithm or not? Discuss in detail. d. (7 pts) Design a recursive algorithm, say RecursiveQ1 algorithm, that solves the same problem. Give the pseudocode of your algorithm. Show the iterations step-by-step of your algorithm for the given instance. e. (2 pts) What is the computational complexity of RecursiveQ1? Is it an efficient algorithm or not? Discuss in detail
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
