\[ D_s(n) = (n) \]
\[ \left [ I, a_0, (a_0\oplus a_1),\cdots,(a_0\oplus a_1 \oplus \cdots \oplus a_{n-2}) \right ] \]
\[ \left [ a_0, (a_0\oplus a_1),\cdots,(a_0\oplus a_1 \oplus \cdots \oplus a_{n-1}) \right ] \]
// exclusive
out[0] = 0;
for (k=1; k<n; ++k)
out[k] = in[k-1] + out[k-1]; \[ T_1(n) = \mathcal{O}(n) \]
(l,m) = select_lower(a, n, pv) {
// t = t[0,...,n-1]
parallel for (i=0; i<n; ++i)
t[i] = a[i] < pv;
s = scan(t);
m = s(n-1);
// allocate l
parallel for (i=0; i<n; ++i)
if (t[i])
l[s[i]-1] = a[i];
}\[W=\mathcal{O}(n), D=W=\mathcal{O}(\log n)\]
scan can be used for any of the problems in assignment 1
parallel for (i)
if (x[i] <= y < x[i+1]) return i; // no duplicatesno parallelism if we insist on work optimality
define:
rank$(z:A) $ number of elements \(a_i|a_i\leq z\)
define:
rank\((B:A) := (r_1,r_2,\cdots,r_t)\)
$r_i$ rank\((b_i:A)\)
b = Merge_Sort(a,n)
if n < 100
return seqSort(a, n);
b1 = Merge_Sort(a[0,…,n/2-1], n/2);
b2 = Merge_Sort(a[n/2,…,n-1], n/2);
return Merge (b1, b2);tradeoffs between
parallel searches using \(p=nm, D=\mathcal{O}(1)\) but \(W=\mathcal{O}(n^2)\)
Concurrent binary searches, \(D=\mathcal{O}(\log n)\) and \(W=\mathcal{O}(n \log n)\)
Goal: Parallelize with optimal work
par_merge\((B_i, A_i)\)\[W=\mathcal{O}(n)\]
and,
\[D=\mathcal{O}(\log n)\]