+ 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.

6th May 2022, 7:15 PM
Lorenzo Lepore
Lorenzo Lepore - avatar
7 Answers
+ 4
I would recommend you to study first given examples of recursion. Rewrite them, change them, write loop versions of them, etc...
6th May 2022, 7:51 PM
Lisa
Lisa - avatar
+ 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.
6th May 2022, 10:13 PM
Ani Jona 🕊
Ani Jona 🕊 - avatar
+ 1
Write recursive functions to practice recursion.
6th May 2022, 7:18 PM
Lisa
Lisa - avatar
+ 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
6th May 2022, 10:13 PM
Rik Wittkopp
Rik Wittkopp - avatar
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
6th May 2022, 7:48 PM
Lorenzo Lepore
Lorenzo Lepore - avatar
0
Would you recommend leetcode for practicing recursion problems?
6th May 2022, 7:49 PM
Lorenzo Lepore
Lorenzo Lepore - avatar
0
Got it, thanks to both! â˜ș
6th May 2022, 8:17 PM
Lorenzo Lepore
Lorenzo Lepore - avatar