Could you explain your answers to these? 1. Given n integers distributed one per
ID: 3716597 • Letter: C
Question
Could you explain your answers to these?
1. Given n integers distributed one per base processor on a tree of base size n, give an algorithm that will result in all base processors knowing the sum of these n integers. An English description is fine – no code is necessary. State and justify the asymptotic running time of your algorithm.
2. Given n integers stored in the first n positions of global memory on a PRAM of your choosing (please state), give an efficient algorithm to determine the number of those integers that are equal to 17. An English description is fine – no code is necessary. State and justify the asymptotic running time of your algorithm.
Explanation / Answer
Solution:
Note: The first question is done as per Chegg guidelines, please repost others.
1)
The algorithm to find sum of integers distributed on processors is given below:
Algorithm:
Correctness:
The above algorithm is running recursively and summing up the value of every node present in the tree to get the final sum.
Running time:
The running time of the above algorithm will be O(n), since we are visiting every node of the tree exactly once.
I hope this helps if you find any problem. Please comment below. Don't forget to give a thumbs up if you liked it. :)