A shuffle function is defined as
Shuffle( A[n-1],A[n-2].....A[1],A[0]) = A[n-2]A[n-3]......A[1],A[0],A[n-1]
where i in A[i] represent the I th bit in the binary representation of the index in the array . The
For example , the shuffle of the third element in an array is fifth array element. i.e..
Shuffle(A[010]) = A[100]. (Assuming the array size as 8 elements)
We see that the n-1 th bit '0' is left circular shifted . So the value of A[4] is copied into A[2]. Can we perform this without using a temporary array for all the elements in the array ...
I want to implement this function in simple plain C , but i just could not understand how to change the bits ...
Suggestions please...