Q803
What will be the time complexity of the following code which raises an integer x to the power y? #include int power(int x, int y) if (y == 0) return 1; else if (y%2 == 0) return power(x, y/2)*power(x, y/2); else return x*power(x, y/2)*power(x, y/2); int main() int x = 2; int y = 3; printf("%d", power(x, y)); return 0;
A.
O(n)
AnswerB.
O(log 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