Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Time complexity of Math.sqrt Java

What is time-complexity of math.sqrt implementation in Java ? Java has time-complexity implemented in some technique whose, time-complexity I am trying to determine.

like image 970
JavaDeveloper Avatar asked Oct 15 '25 08:10

JavaDeveloper


1 Answers

In most cases, Java attempts to use the "smart-power" algorithm, which results in a time-complexity of O(log n). Smart power Algorithm

Also, it appears that in different cases, you could end up with different complexities; Why is multiplied many times faster than taking the square root?

like image 129
Evan Bechtol Avatar answered Oct 16 '25 22:10

Evan Bechtol