Matrix

Friday, 30 January 2015

Week 4: Brackets, Recursion and More Brackets

So starting this week, CSC148 mostly covered the topic of recursion. It sounds overly complicated and extremely confusing but it's not that hard to understand once given examples in class and tutorial. In essence, recursion in computer science consists of defining a function where it applies itself to the definition to solve smaller problems.

The whole idea is pretty foriegn to me since we never really talked about it in my high school CS class. So when my professor first began talking about it, I really had no idea what was going on. But she emphasized that using recursion is vital in programming. You never need recursion technically speaking but it cleans up your code and saves a ton of time.


The examples my professor used in class involved nested lists within lists. And of course going along with that meant brackets, brackets, and more brackets (even more than March Madness). She explained that nasty looking and complicated lists can be simplified and rather than taking using a loop to count the elements, simply use recursion. This began to make more sense to me. Who wants to trek through millions of brackets using a loop?

The other thing she emphasized was tracing the recursion within your code. This not only helps you find mistakes but also understand it better since everything becomes simplified when you are using recursion. This was also the focus of the lab in the tutorial this week which involved tracing functions with recursion.

This week's lectures and tutorials were particulary interesting in showing a method of creating functions that make quick work of complicated and nested inputs. Hard to grasp at first, recursion is actually relatively simple once you understand the core concept of what it does and it will make programming a lot easier.

No comments:

Post a Comment

Matrix