Thursday, March 08, 2007

[Tech] Bitonic Sequences and Bitonic Merge

Given a Bitonic Sequence of length 2n (a motonically decreasing (inceasing) and montonically increasing (decreasing).
If we do a Bitonic merge we still of 2 bitonic sequences of length 'n' each.
void BitonicMerge(int *array,size_t size){
 int i;
 assert(!(size%2));
 for(i=0;i lessthan size/2;i++){
   if(a[i+(size/2)] < a[i]){
     swap(a[i+(size/2)],a[i]);
   }
}

What we have is now two Bitonic sequences. Doing a Bitonic sort on a parallel machines with 'p' processors and 'n' elements n >> p. Next post I'll post my code to do the Bitonic merge of the sequences.

No comments: