Recently asked in interview : Solve the below question and then do it through Map Reduce
There is an array A[N] of N numbers. You have to compose an array Output[N] such that Output[i] will be equal to multiplication of all the elements of A[N] except A[i]. For example Output[0] will be multiplication of A[1] to A[N-1] and Output[1] will be multiplication of A[0] and from A[2] to A[N-1]. Solve it without division operator and in O(n).
I was able to solve it normally but not sure how it can be done using MapReduce.
Normal Solution : Given an array of numbers, return array of products of all other numbers (no division)
n, in might not be strictly possible (independent from the exclusion of division).nmappers andnreducers, and each mapper is getting single element. the number of reducers that needs information from each mapper isn-1- so you are bounded to O(n^2) communication messages.