Question: Algorithm OddEvenMerge ( A , B , C ) : Input: Two sorted arrays, A = [ a 1 , a 2 , . .
Algorithm OddEvenMergeA B C:
Input: Two sorted arrays, A aaan and B bbbn and an
empty array, C of size n
Output: C containing the elements from A and B in sorted order
Let Oaaaan
Let Obbbbn
Let Eaaaan
Let Ebbbbn
Call OddEvenMergeO O O where O o o on Call OddEvenMergeE E E where E e e en Let C oeoeonen
for i to n do
Do a compareexchange of Ci and Ci
return C
Algorithm : Oddeven merge.
are out of order, as an atomic action called a compareexchange. For example, she could use bubblesort Algorithm to sort A since this algorithms is dataoblivious when implemented using the compareexchange primitive. But this would require On time, which is quite inefficient for solving the sorting problem. An alternative is to use the oddeven mergesort algorithm, which is the same as the mergesort algorithm given above, except that the merge step is replaced with the merge method shown in Algorithm Argue why the odd even mergesort algorithm is dataoblivious, and analyze the running time of the resulting sorting algorithm.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
