0000
The elements are taken as input. The array is rotated left (in that case we assume that the program saying about circular array) That means, the element of index 1 is stored in index 0, the element of index 2 is stored in index 1, and so on. And the element of index 0 is stored in index n-1.
INPUT: Array elements
OUTPUT: the array after left rotation
PROCESS:
Step 1: [taking the input]
Read n [number of elements]
For i=0 to n-1 repeat
Read a[i]
[end of ‘for’ loop]
Step 2: [Rotating the array]
Set t<-a[0]
For i=1 to n-1 repeat
Set a[i-1]<-a[i]
[End of ‘for’ loop]
Set a[n-1]<-t
Print “The array after rotation is: “
For i=0 to n-1 repeat
Print a[i]
[End of ‘for’ loop]
Step 3: Stop.
The time complexity to take the number of elements is O(n) and the time complexity to the left rotate is also O(n).
Therefore, the time complexity of this program is O(n).