Reverse a stack using recursion

i have found this code on internet i cant understand this and please explain the logic also

@Learning_bunny hey basically recursion call me apko ye assume krna pdta hai ki hmara kam recursion krke dega hi hme and woh correct hi hoga.
Is reverse function me aisa hi kia hai ,hmne top element of stack ko pop kra dia aur recursion ko keh dia ki baki jo stack bacha hai use reverse kr la ,aur ab recursion hme woh reverse krke la ke dedegi ,ab jo hmne bhar nikala hai element woh first tha to ab use stack ke sabse last me insert krna pdega ,ye kam apna insert function krrha hai,insert bhi recursion use krrha hai ,agr stack empty hai hme tabhi element ko push krna hai kyunki last me insert kerna hai ye base case ho gya,ab pehle element pop kra lia ,abhmne jo insert krana hai element woh recursion se insert kra dia mtlb recursion ne x insert kr dia hoga ab hmne jo y nikala tha use bs push krna hai.Is logic se sochoge to easily smjh ayega ,hope you get it.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.