Complexity of grouping in Java8
I would like to learn the time complexity of the given statement below.(In Java8) list.stream().collect(groupingBy(...)); Any idea? There is no general answer to that question, as the time complexity depends on all operations. Since the stream has to be processed entirely, there is a base time complexity of O(n) that has to be multiplied by the costs of all operations done per element. This, assuming that the iteration costs itself are not worse than O(n) , which is the case for most stream sources. So, assuming no intermediate operations that affect the time complexity, the groupingBy has to