1

I need to give a parallel algorithm which finds the minimal element of an unsorted array. Moreover, I need to show that $T_1 = Θ(n)$ and $T_∞ = Θ(\log n)$.

As I read $Θ(\log n)$, I thought about some sort of divide and conquer algorithm, like MS:

parallelMin(A, l, r):
    if l ≥ r:
        return min(A[l], A[r])
    m = l+⌊(r-l)/2⌋
    x = spawn parallelMin(A, l, m)
    y = parallelMin(A, m + 1, r)
    sync
    return min(x, y)

I know that $T_1(n)=2T_1(n/2)+Θ(1) \Rightarrow T_1(n) = Θ(n)$.

But for $T_∞$, I'm not certain that it is indeed $Θ(\log n)$.

So my questions are:

  1. How do I calculate (and show) $T_∞$? I know that it's the algorithm DAG span, but I would like to learn how to show it.
  2. Can/Should the second call be parallelized too?
Yuval Filmus
  • 276,994
  • 27
  • 311
  • 503
RedYoel
  • 217
  • 1
  • 6

1 Answers1

1

The recursive algorithm can be summarized in one sentence:

Given an unsorted array $A$, break it into two equal halves $B,C$, calculate their minimum elements $\min(B),\min(C)$ in parallel, and output $\min(A) = \min(\min(B),\min(C))$.

When there are infinitely many processors, we can always calculate $\min(B)$ and $\min(C)$ in parallel, and so the recurrence for the running time is $$ T_\infty(n) = T_\infty(n/2) + O(1), $$ whose solution is $T_\infty(n) = \Theta(\log n)$. (We are making the simplifying assumption that $n$ is a power of 2.)

Yuval Filmus
  • 276,994
  • 27
  • 311
  • 503
  • I just want to see if I got it right - it's $T_∞(n/2)$ and not $2T_∞(n/2)$ because the calls are parallel. So in general, when we calculate $T_∞$ we can "count" all identical parallelized calls as one? – RedYoel Jun 13 '21 at 17:07
  • 1
    That's the idea. – Yuval Filmus Jun 13 '21 at 17:23