15.18 The following is a nonrecursive version of MergeSortPRAM.
procedure MergeSortPRAM(L[0:n – 1])
Model: EREW PRAM //the number of processors needed depends on the
//implementation of MergePRAM
Input: L[0:n – 1] (a list of size n = 2k)
of course the initial lists of size 2 are not L[0:1], L[2:3], … , L[n – 2: n – 1], since the list is
split into odd- and even-indexed sublists, as opposed to sublists L[0(n – 1)/2] and L[n/2: n –
1]. In fact, let π : {0, …, n – 1} → {0, …, n – 1} denote the permutation such that
Lπ(0), Lπ(1) , … , Lπ(n-1) is the order in which the list elements occur in leaf nodes of the tree
of recursive calls read from left to right. It turns out that the the k-digit (where k=log2n)
W(n) = W(n/2) + n – 1
= W(n/22) + n(1 + 1/2) – 2
= W(n/23) + n(1 + 1/2 + (1/2)2) – 2
= W(n/2k) + n(1 + 1/2 + (1/2)2 + … + (1/2)k-1) – k
= 0 + n[(1 – (1/2)k)/(1 – 1/2)] – k