Question: For HW 1, you gave pseudocode for summing contributions from each node at node 0. We now know that the same basic algorithm can be
For HW 1, you gave pseudocode for summing contributions from each node at node 0. We now know that the same basic algorithm can be used for other kinds of reductions and not just for sum. Reductions are an important algorithm, but our version is still fairly restrictive. Write pseudocode that sums values but takes the desired destination as an additional parameter. For example, if the additional parameter is 7, then node 7 will calculate the total sum. I suggest that you use the same basic algorithm for this as in HW 1, but build your tree so that the desired node is the root. As with the HW, your code should work even if the number of nodes is not a power of two.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
