Python Program for Reversal algorithm for array rotation
Write a function rotate(arr[], d, n) that rotates arr[] of size n by d elements.
Example :
Input : arr[] = [1, 2, 3, 4, 5, 6, 7] d = 2 Output : arr[] = [3, 4, 5, 6, 7, 1, 2]
Rotation of the above array by 2 will make array
Output :
3 4 5 6 7 1 2
Time Complexity : O(n)
No comments:
Post a Comment
Your feedback is highly appreciated and will help us to improve our content.