Sequential/src/interleaving.c
// Cycle leader algorithm to move all even positioned elements 
// at the end. 
Cycle leader algorithm to move all even positioned elements
at the end.
Cycle leader algorithm to move all even positioned elements at the end .
void cycleLeader( float*buf, int shift, int len){
	int j; 
	float item; 
	for (int i = 1; i < len; i *= 3 ) 
	{ 
		j = i; 
		item = buf[j + shift]; 
		do
		{ 
			if ( j & 1 ) 
				j = len / 2 + j / 2; 
			else
				j /= 2; 
			swap (&buf[j + shift], &item); 
		} 
		while ( j != i ); 
	} 
}
void cycleLeader ( float * buf , int shift , int len ) { int j ; float item ; for ( int i = 1 ; i < len ; i *= 3 ) { j = i ; item = buf [ j + shift ] ; do { if ( j & 1 ) j = len / 2 + j / 2 ; else j /= 2 ; swap ( & buf [ j + shift ] , & item ) ; } while ( j != i ) ; } }
Cycle leader algorithm to move all even positioned elements
at the end.
Cycle leader algorithm to move all even positioned elements at the end .
// odd index  // even index  // keep the back-up of element at new position 