Given the relatively large input volume, it's worth it. Always.
Example: A naive algorithm for finding the largest number in an unordered "list" will simply traverse the list. It takes time of the order of O(n)
to find the record.
This is normal if you have 100 or 1000 entries.
What if you had a billion records? You split the list among several processors, each finds a maximum, then you have a new smaller list for work. You can split it again => Parallel and faster. I believe this is O(log(n))
if you effectively split and reduce and have n processors .
Point: if your input is large enough, O(n)
no longer enough. Depending on what needs to be done, O (n) can grow to too many seconds, minutes, hours compared to what you would like.
Note. When I say O(n)
or O(log(n))
above, I mean the time taken to complete the search. that is, not the "common work" performed by all CPUs. Typically, parallelizing an algorithm increases the overall work performed by processors.
Arjunshankar
source share