Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Time complexity of c++ math library pow() function?

Tags:

I wanted to know what is the worst case time-complexity of the pow() function that's built in c++?

like image 288
uda27 Avatar asked Nov 16 '12 14:11

uda27


People also ask

What is the time complexity of POW function in C?

Time Complexity: O(N) because pow(x,n) is called recursively for each number from 1 to n.

What is the time complexity of math POW?

You can consider Math. pow to be O(1).

Is POW a library function in C?

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.

What C library is POW in?

pow() function in C It is declared in “math. h” header file.


1 Answers

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

like image 139
Magnus Hoff Avatar answered Sep 30 '22 20:09

Magnus Hoff