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

Which sentence best describes the relationship between William and the people who doubted him? * A. William was inspired and delighted by them. B. William ignor
Dramatic Irony occurs when characters are unaware of the information that the audience knows. Choose the option below which shows a list of dramatic irony as se
pls help Asapppppppppp.It is due in a little bit.
Please help; with an explanation to these please
Solve the formula Ax+By = C for A. O A A+ + By O B. A=C-BY x O C. A = C+By O D. A = C-BY X
how do you know this pile of laundry is a mmixture plz help
WHAT IS Poincaré Conjecture
If cos a= 0.93. Sin 0 =0.26, and tan ß = 0.84, find a + B + 0.
An Allele which express itself during gamete formation is termed as:
What is the slope of the line?​