Java中不同集合的时间复杂性

时间:2022-10-02 07:44:36

Most of the cases in competitive programming it is necessary to know about the complexity of a code before use it. We uses different library functions and STL in C++ coding. And there is a beautiful documentation on STL with complexities.

竞争性编程中的大多数情况都需要在使用之前了解代码的复杂性。我们在C ++编码中使用不同的库函数和STL。关于STL的复杂性有一个很好的文档。

I want to know about the complexities of different built in generic Collections methods (e.g. complexity of java.util.Arrays.sort()) in java. Is there any proper documentation about the complexities in Java all together?

我想知道java中不同的内置泛型集合方法的复杂性(例如java.util.Arrays.sort()的复杂性)。是否有关于Java复杂性的适当文档?

Thanks in advance.

提前致谢。

1 个解决方案

#1


1  

Please read official Oracle documentation with attention, for example cite from (https://docs.oracle.com/javase/7/docs/api/java/util/Arrays.html#sort(byte[]) ) -

请仔细阅读官方Oracle文档,例如来自(https://docs.oracle.com/javase/7/docs/api/java/util/Arrays.html#sort( byte [])) -

Implementation note: The sorting algorithm is a Dual-Pivot Quicksort by Vladimir Yaroslavskiy, Jon Bentley, and Joshua Bloch. This algorithm offers O(n log(n)) performance on many data sets that cause other quicksorts to degrade to quadratic performance, and is typically faster than traditional (one-pivot) Quicksort implementations.

实施说明:排序算法是Vladimir Yaroslavskiy,Jon Bentley和Joshua Bloch的双枢轴快速算法。该算法在许多数据集上提供O(n log(n))性能,导致其他快速排序降级为二次性能,并且通常比传统(单枢轴)Quicksort实现更快。

As you can see O(n log(n)) is specified

如您所见,指定了O(n log(n))

#1


1  

Please read official Oracle documentation with attention, for example cite from (https://docs.oracle.com/javase/7/docs/api/java/util/Arrays.html#sort(byte[]) ) -

请仔细阅读官方Oracle文档,例如来自(https://docs.oracle.com/javase/7/docs/api/java/util/Arrays.html#sort( byte [])) -

Implementation note: The sorting algorithm is a Dual-Pivot Quicksort by Vladimir Yaroslavskiy, Jon Bentley, and Joshua Bloch. This algorithm offers O(n log(n)) performance on many data sets that cause other quicksorts to degrade to quadratic performance, and is typically faster than traditional (one-pivot) Quicksort implementations.

实施说明:排序算法是Vladimir Yaroslavskiy,Jon Bentley和Joshua Bloch的双枢轴快速算法。该算法在许多数据集上提供O(n log(n))性能,导致其他快速排序降级为二次性能,并且通常比传统(单枢轴)Quicksort实现更快。

As you can see O(n log(n)) is specified

如您所见,指定了O(n log(n))