+ 1
Trying to improve my skills on C recursion
Hi, I've been studying C at college and soon I will have to take a test on it. I know that my teacher is particularly focused on recursion at the exam, even if he didn't explain much about it during the course. We studied basics of C, and we finished our course with single and doubly linked list. What I can do to improve quickly? I'm looking to become quite skilled about recursion because other exams of my cs degree will require a complete comprehension of it.
7 Respostas
+ 4
I would recommend you to study first given examples of recursion. Rewrite them, change them, write loop versions of them, etc...
+ 2
Learn to understand the nature of a problem and its dependency on some form of size.
Learn to recognise how a solution of the problem expresses itself in terms of a solution of the same nature, but smaller size.
Lastly, study how the given examples in this thread solve their respective problem assuming the problem of smaller size is solved.
Then you understand the essence of recursion.
+ 1
Write recursive functions to practice recursion.
+ 1
Lorenzo Lepore
" My problem is that I don't know when a function could be converted into a recursive one"
Recursion is similar to a while loop in that you need a base case to break the loop.
So, if you can identify your base case, then you can write your code to meet it - recursively
0
On what? My problem is that I don't know when a function could be converted into a recursive one...Also I would like to practice simple problems to get a grasp of the concept, then trying to resolve intermediate and hard ones
0
Would you recommend leetcode for practicing recursion problems?
0
Got it, thanks to both! ☺️