Tuesday, 1 March 2016

Week 7: Recursion

Recursion, a word that for some reason brings up fear in almost all pre 148 computer science students. Well Monday I walked into class to find a worksheet with that dreaded word at the top. I found myself picturing all of the new possibilities with Recursion. I can write code that has a finite depth, without coding for the number of layers. The first example of a list of lists of unknown depth was really interesting. Without recursion I have no idea how to sum up all the elements or do some small search. Now with just a few lines of code I can do way more operations then any mess of nested for loops. Recursion looks a lot cleaner and using the method of solving the base case (depth of 0) and then looking at it for each subsequent depth case made creating recursive code a breeze.

I am not sure if this was planned, but two of my other classes also started recursion at the same time. CSC165 and MAT137 started defining sequences recursively. I must admit that this was overwhelming at first, but the more recursive problems I solve, the more comfortable I become. It's a new way of thinking and requires spending a lot more time per line of code compared to before.

Where is recursion taking me? Assignment two was posted this weekend and it is very obvious that I will be using recursive searching to find future moves for solving puzzles and weather a solution is a still a solutions available. The introduction to recursion has changed the way I approach computer science problems and I look forward to writing more code with it.

No comments:

Post a Comment