RIGHT ROTATION

In right rotation, each element of the array will be shifted to its right by one position and the last element of the array will be kept at the first index. This process is continued a specified number of times, till the required output is obtained.

Lets take the same example array: 1,2,3,4,5 and right rotate it 3 times.

The array will look as follows after

  • the first rotation

                                      5 1 2 3 4

  • the second rotation

                                      4 5 1 2 3 

  • the third rotation

                                      3 4 5 1 2

 

So the output should be 3 4 5 1 2.

22

12