Java 7的BigInteger操作有多复杂? [英] What complexity are operations on Java 7's BigInteger?

查看:126
本文介绍了Java 7的BigInteger操作有多复杂?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

方法的复杂程度乘以除以 pow 目前在 BigInteger ?没有提到文档中的计算复杂性(也没有提到其他任何地方)。

What complexity are the methods multiply, divide and pow in BigInteger currently? There is no mention of the computational complexity in the documentation (nor anywhere else).

推荐答案

如果你看一下<的代码code> BigInteger (随JDK提供),在我看来
multiply(..) O(n ^ 2)(实际上该方法是 multiplyToLen(..))。其他方法的代码有点复杂,但你可以看到自己。

If you look at the code for BigInteger (provided with JDK), it appears to me that multiply(..) has O(n^2) (actually the method is multiplyToLen(..)). The code for the other methods is a bit more complex, but you can see yourself.

注意:这是针对Java 6.我假设它在Java中没有区别7。

Note: this is for Java 6. I assume it won't differ in Java 7.

这篇关于Java 7的BigInteger操作有多复杂?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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