Reputation:
If you have one huge amount of numbers and one hundred computers, How would you find the median of the numbers?
Upvotes: 21
Views: 8385
Reputation: 6390
Use selection algorithm.
this solution has an avg runtime of O(n) in order to make it asymptotic runtime of O(n), each processor should split the numbers to groups of 5 elements find the median of each group (using insertion sort) and send those medians back to the leader, the leader will choose the median of those medians (using the same algorithm) and that will be the pivot
read the wiki article - http://en.wikipedia.org/wiki/Selection_algorithm
Upvotes: 21