This cannot be done in O(log(N)) . This is O(N) in the best / worst / middle case, because you would have to visit each element in the array to determine if it is large or not. The array is unsorted, which means you cannot cut corners.
Even in the case of parallelization, this cannot be done in O(N) , because Big-O notation does not care about how much CPU has or what frequency each processor has. It abstracts from this specifically to give a crude problemat problem.
Parallelization can be neglected, since the time taken to split the task can be considered equal to the time of sequential execution. This is because constants are not taken into account. All of the following:
O(N) = O(Const * N) = O(N / Const) = O(N + Const) = O(N - Const)
On the other hand, in practice, parallel separation and control algorithms can give you some performance advantages, so they can work a little faster. Fortunately, Big-O does not deal with this fine-grained algorithmic complexity analysis.
oleksii
source share