Question: This problem is from JaJa, J., An Introduction to Parallel Algorithms, Addison-Wesley, 1992. Suppose we are given a set of n elements stored in an

 This problem is from JaJa, J., An Introduction to Parallel Algorithms,

This problem is from JaJa, J., An Introduction to Parallel Algorithms, Addison-Wesley, 1992. Suppose we are given a set of n elements stored in an array A together with an array L such that L[i] is a label for A[i] Each label L[i] is an integer in the range 1 to 5 Develop an O(log n) time, O(n) work EREW algorithm that rearranges the elements of A such that A consists of all of the elements with label 1, followed by all of the elements of label 2, followed by all of the elements of label 3, and so on. Further, all of the elements of label 1 should be in the same order in the rearranged A as they were in the original A. Here is an example: A = 6 8 5 3 4 1 2 10 7 4 3 L = 3 4 2 2 1 4 2 1 1 2 3 The rearranged A looks like: A = 4 10 7 5 3 2 4 6 3 8 1

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!