Does anyone know what the time complexity of java.util.stream.Stream
is?
Well, sorted()
in itself is O(1), since it's an intermediate operation that doesn't consume the stream, but simply adds an operation to the pipeline.
Once the stream is consumed by a terminal operation, the sort happens and either
Arrays.sort()
(O(n log n))Arrays.parallelSort()
(O(n log n))