I wanted to know what is the worst case time-complexity of the pow() function that's built in c++?
Time Complexity: O(N) because pow(x,n) is called recursively for each number from 1 to n.
You can consider Math. pow to be O(1).
C library function - pow() The C library function double pow(double x, double y) returns x raised to the power of y i.e. xy.
pow() function in C It is declared in “math. h” header file.
That depends on the underlying architecture. On the most common desktop architecture, x86, this is a constant time operation.
See this question for more details on how it could be implemented on x86: How to: pow(real, real) in x86
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With