简体   繁体   English

Java中Integer乘法的渐近复杂性是什么

[英]What is asymptotic complexity of Integer's multiplication in Java

I am interested in asymptotic complexities of multiplication operations for int type, Integer and BigInteger objects: 我对int类型, IntegerBigInteger对象的乘法运算的渐近复杂性感兴趣:

int i,j = <value>;
i * j; // O?
Integer i,j = new Integer(<value>);  
i * j; // O?
BigInteger i,j = new BigInteger(<value>);
i.multiply(j); //O?

BigInteger.multiply uses multiple algorithms, depending on the size of the number. BigInteger.multiply使用多种算法,具体取决于数字的大小。

Small numbers use naive algorithm O(n^2) 小数使用朴素算法O(n ^ 2)

Larger numbers use Karatsuba algorithm O(n^1.585) 较大的数字使用唐津算法O(n ^ 1.585)

Largest numbers use Toom–Cook algorithm O(n^1.465) 最大数使用Toom–Cook算法O(n ^ 1.465)

I could not easily determine the threshold of the length of the number used to determine which algorithm to use. 我无法轻易确定用于确定使用哪种算法的数字长度的阈值。 Please edit my answer if you know this. 如果您知道这一点,请编辑我的答案。

int multiplication is O(1) because the size of the integer (n) is a constant value 因为整数(n)的大小是一个常数,所以int乘积是O(1)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM