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

What value of c makes the polynomial below a perfect square? x2 + 16x + c c = A. 64 B. 32 C. 4 D. 256
who invented the telephone? a) alexander graham bell b) cyrus field c) thomas edison d) lewis latimore
2684 correct to 2 significant figures
Which is a major risk factor for suicide? A a history of violence B sleeplessness C the need for counseling D mood disorders
How many times does 23 go into 194?
what are the factors of 5x^2 + 39x - 8 ?
The ____ consists of everything inside the plasma membrane of the cell.
PARIS: Happily met, my lady and my wife! JULIET: That may be, sir, when I may be a wife. PARIS: That may be must be, love, on Thursday next. JULIET: What must
how many people are there on earth
If a bullet loses 1/nth of its velocity while passing through a plank,then no of planks required to stop the bullet is?