Reverse order of elements of an array

Reverse order of elements of an Array


Iterative way

Initialize start and end indexes

start = 0, end = n1

In a loop, swap arr [start] with arr [end] and change start and end as follows.

start = start + 1, end = end – 1.

Recursion way

Initialize start and end indexes

start = 0, end = n1.

Swap arr [start] with arr[end].

Recursively call reverse for rest of the array.

For example if a is an array of integers with three elements such that

a [0] = 1

a [1] = 2

a [2] = 3

Then on reversing the array will be

a [0] = 3

a [1] = 2

a [0] = 1

Python : Reverse order of elements of an array Program List




CCC Online Test 2021 CCC Practice Test Hindi Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level NIELIT Study material and Quiz Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Sarkari Naukari Notification Best Website and Software Company in Allahabad Website development Company in Allahabad