0000
The elements of the array are taken as input. The program reverses the array elements and stored into another array in reverse order.
INPUT: The array elements
OUTPUT: The Reversed array
PROCESS:
Step 1: [taking inputs from user]
Read n [number of elements]
For i=0 to n-1 repeat
Read a[i]
[End of ‘for’ loop]
Step 2: [Finding the reverse of the array]
j=0
for i=n-1 to 0 repeat
b[j]=a[i]
Set j<j+1
[End of ‘for’ loop]
Step 3: Stop.
The time complexity to take the number of elements is O(n) and the time complexity to reverse the array is also O(n).
Therefore, the time complexity of this program is O(n).