How can i write a code that reverses an array using recursion in c++ | SoloLearn: Learn to code for FREE!

-1

How can i write a code that reverses an array using recursion in c++

6/3/2020 5:27:29 PM

M .Queen

4 Answers

New Answer

+4

AMOGHA. A. K. If you are unable to answer why you take credits of author & just copy paste answers here you can give links & user can visit it Don't do such things again https://stackoverflow.com/questions/49930296/recursively-reverse-an-array

+2

M .Queen Have you tried it? plz share whatever you have tried

0

The logic is simple, swap arr[start] with arr[end] then recursively call reverse for rest of the array. ... If your array is initially 1 2 3 4 5 , here's the sequence of swaps at each recursion step: swap 0 and 4 : 5 2 3 4 1. swap 0 and 3 : 4 2 3 5 1. swap 0 and 2 : 3 2 4 5 1. swap 0 and 1 : 2 3 4 5 1.

-1

𝐊𝐢𝐢𝐛𝐨 𝐆𝐡𝐚𝐲𝐚𝐥 I saw that answer on stackoverflow i just didn't understand why and how it worked so recursion functions is a trouble and cuz it's in array also i found it difficult so i wanted to know the logic and how to do it in array .. i solves it now thanks for ur efforts .. U AMOGHA. A. K. What !? I would not copy paste i am a programmer and i am learning ! Not stealing