We have already discussed how distributed computing works in this book. In this section, we will try to understand distributed computing with a small example that works on arrays.
Let's say we have an array of 1,040 elements and we would like to find the sum of all the numbers:
a = [1,2,3, 4...., n]
If the total time that's taken to add numbers is x (let's say all of the numbers are large) and we want to compute them all as fast as possible, we can take advantage of distributed computing. We would divide the array into multiple arrays (let's say, four arrays), each with 25% of the original number of elements, and send each array to a different processor to calculate the sum, as follows:
In this arrangement, the total time that's taken to add all the numbers is reduced to (x/4 + d) or (x/number of processors +d), where...