The following is the best estimate:
If p <= n / log n, you can do it in O (n / p); otherwise O (log n), i.e. when p> n / log n you get nothing compared to p = n / log n.
Proof - lower bound:
Requirement 1: you can never do faster than Ω (n / p), since p-processors can only give acceleration p
Requirement 2: you can never do faster than Ω (log n), because of the CREW model (see waterproof paper); if you want to check if the array 0-1 has at least one 1, you need O (log n) time.
Proof - upper bound:
Requirement 3: you can find the maximum using n / log n processors and in O (log n) time
Evidence. It is easy to find the maximum using n processors and log n time; but in fact, in this algorithm, most processors are inactive in most cases; (see, for example, the book of complexity Papadimitriou) their number can be lowered to n / log n.
Now, given fewer n / log n processors, you can give the work assigned to processors K to 1 processor, this divides the processor requirement by K and multiplies the required time by K.
Let K = (n / log n) / p; the previous algorithm works in time O (K log n) = O (n / p) and requires n / (log n * K) = p processors.
Edited: I just realized that when p <= n / log n, the dasblinkenlight algorithm has the same asymptotic runtime:
n / p + log p <= n / p + log (n / log n) <= n / p + log n <= n / p + n / p <= 2n / p = O (p / p)
so that you can use this algorithm which has O (n / p) complexity when p <= n / log n and O (log n) otherwise.
sdcvvc
source share