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

Programs

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