Vidyalelo
Data Structure · Q668

Miscellaneous on Data Structures

Programming · Data Structure · question 668

Q668

What will be the time complexity of the following code? int xpowy(int x, int n) if (n==0) return 1; if (n==1) return x; if ((n % 2) == 0) return xpowy(x*x, n/2); else return xpowy(x*x, n/2) * x;

A.
O(log n)
Answer
B.
O(n)
C.
O(n log n)
D.
O(n2)

Answer: Option A

Solution

Answer: Option A
No explanation is given for this question Let's Discuss on Board