I am not able to understand recursions

I can understand recursions that are shown to me (I learnt it recently). But I am not able to create recursions on my own. I have to look for the answer and blindly copy and paste. And then understand the code(I can do that, but I get stuck in that too). But when will I learn to create things on my own.
I can understand complex stuff, only if the answer/solution/whatever is shown. Only then I can understand stuff.
Could please help me by creating a few recursions to help me understand these better. This concept is really confusing and annoying me.

Hey there~!

I’m going to link to a post I made on another topic that includes a breakdown of how recursion works - let me know if this helps.

Hi @gururajankappa

Could please help me by creating a few recursions to help me understand these better. This concept is really confusing and annoying me.

You can use http://pythontutor.com/ if you want to “debug” (step by step execution) the code, here an example of recursion:

Cheers and happy coding :slight_smile:

2 Likes

I didn’t quite get anything.

Edit :- Oh! I got it now.

Sorry for asking too many questions. Why should we :-
return sum(arr, n - 1) + arr[n - 1];
And return 0;
If, at the end it has to return 0 anyways(when it reaches the base case).
Why do we have to do:-
arr[n-1] .
How good of a programmer am I(I want a very honest answer, I won’t feel bad)?
NOW this question might seem stupid to you. But you should know that I am not very good at math.
Of course googling is good. But…I think your getting me…but we can’t google concepts(Unless we fully understand it)…we can look up for methods, css properties, “how to make a navbar” etc.
I am able to understand the code. But I am not able to write a recursion on my own.
Some more explanatory videos and explanatory replies will be appreciated.
Could you teach me something common in all recursions. And then apply them to specific types of problems, and then apply THEM to specific QUESTIONS

I am so sad to say that I haven’t understood anything.
I appreciate your hard work!

Just watch the whole video. You’ll learn everything you need to know(In detail)