-
Notifications
You must be signed in to change notification settings - Fork 0
Abstraction for Fold and Scan
Let
First, consider a rooted binary tree
Any rooted binary tree
Further assume that each leaf node
Notice that this fold
operation essentially takes a tree with data attached to the leaves and propagates it such that data is now defined at every node (as the value
Consider a case where we are given an ordered array of data
A non-parallel sum of three elements would look like this
graph TD;
s0["sum 0"] --> 0;
s0 --> x0["x[0]"];
s1["sum 1"] --> s0;
s1 --> x1["x[1]"];
s2["sum 2 (final sum)"] --> s1;
s2 --> x2["x[2]"];
A parallel sum of three elements might look like this
graph TD;
s0["sum X"] --> x0["x[0]"];
s0 --> x1["x[1]"];
s1["sum Y"] --> x2["x[2]"];
s1 --> x3["x[3]"];
s2["sum Z (total sum)"] --> s0;
s2 --> s1;