https://kotlinlang.org logo
#science
Title
# science
s

Sharan Salian

08/25/2022, 6:45 AM
Hello, Topic: Computer Science Q: What is the time complexity of the standard library filter function? Context: I wrote an algorithm for Quick Sort but for large data sets I'm getting Time Limit Exceeded. Algorithm
i

Ilya Muradyan

08/25/2022, 7:12 AM
Hello. Complexity of filter is linear. But there are too many memory allocations in your implementation, that's why your solution is expected to be slow. Moreover, it's better to choose another strategy for finding pivot: it's easy to construct an array which will result in O(n^2).
4 Views