Friday, September 27, 2024
Google search engine
HomeData Modelling & AIAlgorithms | Divide and Conquer | Question 5

Algorithms | Divide and Conquer | Question 5

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

Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!

RELATED ARTICLES

Most Popular

Recent Comments