List-Rank(L) foreach processor i, in parallel ; O(1) if next(i) = NIL then d(i) = 0 else d(i) = 1 while next(i) NIL for some i ; test foreach processor i, in parallel ; O(1) if next(i) NIL ; synchronize then d(i) = d(i) + d(next(i)) next(i) = next(next(i))
Click mouse to advance to next frame.
List-Rank halves the lengths of the lists each time, thus O(lg n) times through while loop.