Saturday, February 27, 2016

Recursion (Week 6)

Recursion. It's a concept I've heard before in computer programming, where your implementation of a function calls the function itself one or more times in its body.

Recursion makes certain functions easier to implement, such as calculating the sum of nested lists or a factorial. It comes with two parts: the base case and the general case.

Tracing a recursive function seems pretty trivial to me, but designing a recursive function doesn't feel very easy. I always had trouble figuring out the general case, especially during the lecture exercises. Luckily, understanding recursion only comes with lots and lots of practice, and I plan to get a lot of that from looking at the example code or practice making recursion functions.

As for infinite recursion, I won't have trouble with that since figuring out the base case for recursive functions seems pretty easy to me, and base cases are termination conditions for recursive functions.

There was also a lab somewhere in the 6th week, but I don't think there was anything special there (other than learning about two built-in functions, zip and filter).

No comments:

Post a Comment