Open In App

Algorithms | Divide and Conquer | Question 5

Like Article
Like
Save
Share
Report

Consider a situation where you don’t have function to calculate power (pow() function in C) and you need to calculate x^n where x can be any number and n is a positive integer. What can be the best possible time complexity of your power function?
(A) O(n)
(B) O(nLogn)
(C) O(LogLogn)
(D) O(Logn)


Answer: (D)

Explanation: We can calculate power using divide and conquer in O(Logn) time. See https://www.geeksforgeeks.org/write-a-c-program-to-calculate-powxn/.


Quiz of this Question


Last Updated : 28 Jun, 2021
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads