findind it very difficult to understand recursion.
i have some computer knowladge from the past, but i had big problems to keep learning and sitting on the computer for long times, and i stopped at the first problem to understand or when something hard came by.
i thought its not my area of interests, but i found this problem in other areas, i decided to try and learn it again(im 22) and take an open university course which will only start in 5 months(java) but really wanted to learn it by myself so the course also will be easier but also would may like to work in this field in the future. (you have to take the java course for comp siensce no matter what you know).
the thing is, that since highschool, when i tried understanding recursion i was blasted with confusing thoughts.
i just cant get to grasp this idea for some reason, and when i think and look about a code(well mostly with return which is most of the recursion codes, just output and then another call with if is easy to grasp).
i had problems with it a few years ago, and then i stopped with programming, but got the same feelings yesterday which again got me a little unmotivated.
i know its one of those things that hard until you grasp it.
so how do you develop recursion thought? i read something about math induction(no idea what it is) to grasp it.
even small code like this:
so dont talk about bigger ones with trees/list etcs....
public int sum(int n)
if( n <= 9)
return sum(n / 10) + n % 10;
i just cant grasp the idea and when i look at it i just dont know what to do with the input.
is recursion something you need to do on paper step by step? or when you grasp it it becomes second nature?
how can i understand this concept for good? i know its a function calling itself, and know its got to have a stopping one, but nothing else. well i know alot but nothing is getting in about this subject.
i would really really appreciate your help in the subject.
how long btw it took you to learn and understand recursion? what should i do to understand it best?
big thank you,