Suppose we have an array and we want to find K its smallest values:
There are two approaches:
1.Using the quick selection algorithm (O (n) time complexity and O (1) space)
2. Using a minimal heap data structure (O (NlogK) and O (K) time complexity)
I would like to know when someone prefers another.
I think both of them can be distributed.
source share