CISC621 -- Fall 1999 -- HOMEWORK 6
Handed out: November 23, 1999
Due date: December 7, 1999
16. [Group Problem] Group 7 grades this problem
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 k, where k is a constant.
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 9 7 4 3
-
L = 3 4 2 2 1 4 2 1 1 2 3
The rearranged A looks like:
-
A = 4 9 7 5 3 2 4 6 3 8 1
(This problem is from JaJa, J., An Introduction to Parallel Algorithms,
Addison-Wesley, 1992.)
17. [Individual Problem] Laskov grades this problem
Do either of CLR problems 32.1 or 32.2. Your choice.
18. [Individual Problem] Saunders grades this problem
Do any chapter-end problem from CLR, excluding those done for any
of homework problems 1-17.
This does not include section end "exercises" within chapters.
As always, include a statement of the problem (as well as identifying
it by it's CLR number). In this instance, I will not be at all willing to
read solutions without problem statements.
B.D. Saunders
November 23,1999