Professional Documents
Culture Documents
Team 2
if (arr[mid] == 1):
return firstZero(arr, (mid + 1), high)
else:
return firstZero(arr, low, (mid - 1))
return -1
if (first == -1):
return 0
return (n - first)
2. Write parallel programs to compute the summation of n integers. Assume
that n is a power of 2. Partition the n integers into n/2 pairs. Use n/2
processes to add together each pair of integers resulting in n/2 integers.
Repeat the method on the n/2 integers to obtain n/4 integers and continue
until the final result is obtained. (This is a binary tree algorithm). Assume
shared memory.
path_sum = *s1;
recv(&part_sum1, P1);
part_sum = part_sum + part_sum1;
recv(&part_sum1, P2);
part_sum = part_sum + part_sum1;
recv(&part_sum1, P4);
part_sum = part_sum + part_sum1;