We have to use 3 MPI communications: Plz the code in C++ 1. MPI_Scatter
3. MPI_Gather **The length of the array will be determined by the user First we create an array in the master processors and fill it by random numbers. Then we divide the the length of the array by the number of the slave processors. In each slave processor we create to buckets(arrays).
The first one is n/p (n= length of big array, p= number of processor) and the second array is n length.
Then we use MPI_Scatter to send each part of the big array to each first bucket of slave processor.
Then we use any sort functions to sort the the buckets.
Then we divide the small buckets by number of slave processors.
After that we use MPI_Alltoall to send all the first parts of small buckets to array 2 in processor 1 and so on for all second parts to array 2 in processor 2.