Understanding recursion takes a lot of practice. The way we were taught to think about it was to first think about the base case of the function you are designing, what the function returns at the end of the recursive chain, so to speak. After you have designed the base cases, you think about small scale cases of how the function works before the base case. This is the hard part, and requires a ton of thinking. After you get through this step, combine the 2 above steps and you should have a working recursive function.
I feel that I have a good grasp of recursion at this point in the course, mainly due to working on the labs for this course. Tracing recursion was simple enough, but making recursive functions took a lot of practice and thinking, especially for the course's second assignment. Hopefully this practice will pay off in my future as a computer scientist.
No comments:
Post a Comment