PrincessCuCu9712 PrincessCuCu9712
  • 22-08-2019
  • Computers and Technology
contestada

)the efficiency for recursuvely calculating xn is

A.O(nlogn)

B. O(n)

C.O(logn)

D.O(n2)

Respuesta :

ExieFansler ExieFansler
  • 28-08-2019

Answer:

(B) O(n).

Explanation:

When we recursively calculate xⁿ. We multiply x with itself  n times.in doing so we have to do this operation n times .So the time complexity will come out to be O(n).

for ex:

int product(int a ,int n)

{

   if(n==1)

   return a;

   return a*product(a,n-1);

}

This function will keep on doing these operation until it hit the base case it is doing the operation n times.

Answer Link

Otras preguntas

PLEASE HELP ASAP AND GIVE A REAL ANSWER Different sizes of string needs to be cut to go around various shapes. All of the following sizes are in inches 2 44 16
Find the average rate of change of g(x) =-x²+2x+2 from x=2 to x = 6. Simplify your answer as much as possible.
Your gross income is $4,520.00/month. Your deductions are FICA (7.65%), federal tax withholding (11.75%), and state tax withholding (8.5%). Your fixed expenses
2x - 4y = -2 2x + 3y = -16 What is the solution
What is the proper identifier for the following figure:
How to use Preposition and Articles in a sentence?
help, please in this problem
describe coraline's personality and how is she different from traditional heroes​
PLEASE HELP ME I WILL MARK BRAINLIEST!! :)
Can someone help me with this? Thank you so much! I mark as brainliest :))