Question: Consider the following Algorithm: ALGORITHM P (n) //Input a positive integer n i1j0fork1tondoji+jijireturnj 1. a) What does this algorithm return when n=1,n=2,n=5 ? 2. b)

Consider the following Algorithm: ALGORITHM P (n) //Input a positive integer n i1j0fork1tondoji+jijireturnj 1. a) What does this algorithm return when n=1,n=2,n=5 ? 2. b) What is its basic operation? 3. c) How many times is the basic operation executed? 4. d) What is the space cost of the algorithm expressed in big-Theta? 5. e) What is the efficiency class of the algorithm? Show any assumptions you made to arrive at your answer. Indicate whether the efficiency class is constant, linear, quadratic, exponential, etc. in the input size
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
