I know that juggling works for left rotation. Does right rotation fit for juggling algorithm ? If so, then what has to be modified for it to work for right rotation?
Left rotation using juggling algorithm
Reference taken from 3rd method on the below link
/*Function to left rotate arr[] of siz n by d*/
void leftRotate(int arr[], int d, int n) { int i, j, k, temp; for (i = 0; i < gcd(d, n); i++) { /* move i-th values of blocks */ temp = arr[i]; j = i; while(1) { k = j + d; if (k >= n) k = k - n; if (k == i) break; arr[j] = arr[k]; j = k; } arr[j] = temp; } }
Pls help me whether it supports or not