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

Factor Completely: 25x2 - 64
The nurse is performing a nutrition assessment of a client from the middle east. what may the nurse expect as a traditional breakfast consumed by a client from
PLEASE HELP! Why did nuclear arms remain a threat after the Cold War? A. Israel, India and Pakistan refuses to reduce their stock of nuclear weapons B. The old
2:12 in how do write 2:12hr in french french language
In order to be​ successful, money in a fiduciary monetary system must have
How are pathogens trapped by and expelled from the respiratory system?
How did the cuban effect the relationship between the united states and soviet union??
which of the following events helped the women's movement develop? a) the civil rights movement b) the publication of Ms. magazine c) the work of Phyllis Shafl
What's equivalent to a2/3
What is 4.21 rounded to the nearest tenth?