parallel algorithm course 05
linked list
omp task
array pool
use array to simulate linked list
e.g. 1
find prev using next
e.g. 2
find index
prev
jump
repeat:-for i from 0 to n-1:
parif NULL: continue
if prev[i] != empty:
+= rank[prev[i]] # initial all 1 except head is 0
rank[i] = prev[prev[i]] # use 2 copies to avoid data racing prev[i]
\(T_1(n)=O(n\cdot log(n))\)
\(T_\infty(n)=O(log(n))\)
Wyllie’s Alg: jump
e.g. Tree
similar: binary lifting
improve Wyllie’s Alg
\(O(n\cdot log(n))\rightarrow O(n)\)
step 1: shrink \(n\rightarrow m\)
step 2: call Wyllie’s Alg \(O(m\cdot log(m))\)
step 3: restore \(m\rightarrow n\)
target \(m\rightarrow \frac{n}{log(n)}\)
independent set \(\forall i \in I,N(i) \notin I\)
symetry break
random flip coin, keep or remove
resolve confict
# producing independent set
-for i=1..n
par= RND(0 or 1)
F[i] -for i=1..n
parif F[i]=F[N[i]]=1: # data racing. need 2 copies
= 0 F[i]
\(T_1(n)=O(n)\)
\(T_\infty(n)=O(1)\)
\(\mathbb{E}|I|=\frac{n}{4}\)
\([n]/I\rightarrow \frac{3}{4}n\) repeat \(loglog(n)\) times \(\frac{n}{log(n)}\)
initialized with 1 except head
repeatedly remove an independent set \(S\) til #rest=\(\frac{n}{logn}\) (change
next[prev[i]]
tonext[i]
, addcounter[i]
tocounter[next[i]]
forall \(i\in S\))call Wyllie’s Alg
reverse
quick sort: choose 1 pivot, sample 1
v.s.
sample sort: randomly choose \(p-1\) pivots, sample \(k\cdot p+1\)
compact operator