Skip to content

Latest commit

 

History

History
20 lines (18 loc) · 449 Bytes

README.md

File metadata and controls

20 lines (18 loc) · 449 Bytes

Right shift algorithm

Time: formula Space: formula

void rightShift(int a[], int n, int d){
    int i, b[n];
    for(i=0;i<n;i++){
        if(i+d>=n)
            b[i+d-n]=a[i]; 
        else
            b[i+d]=a[i];
    }
    for(i=0;i<n;i++)
        a[i] = b[i];
    for(i=0;i<n;i++)
        cout<<a[i]<<" ";
}