Math.sqrt Java 的时间复杂度 [英] Time complexity of Math.sqrt Java

查看:49
本文介绍了Math.sqrt Java 的时间复杂度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Java 中 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.

推荐答案

在大多数情况下,Java 尝试使用smart-power"算法,这会导致 O(log n) 的时间复杂度.算法

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?

这篇关于Math.sqrt Java 的时间复杂度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆