Friday, 28 February 2014

Recursion

Recursion is a method of problem solving in which you break apart a problem into less complex instances of itself in an attempt to find solution. This will hopefully break down into a simple base case which once solved can solved a more complex iteration of the problem, eventually leading up to the solution of the original problem.

In my experiences, recursion has been more like... trying to break down a problem into a simpler form and ending up confused for a few hours. Lately this has become easier as struggling with it during the assignment forced me to think about it in different ways, leading me to a way of breaking down the original problem that seems to work better for me. Instead of thinking of a slightly simpler instance of it, I try and imagine what steps are involved and how they link together.

As for the power of recursion, it does indeed simplify problems once you obtain a recursive formula or algorithm as it automates the process of solving the problem and you can simply extend the formula for specific cases.

Saturday, 15 February 2014

Week 6 - Trees and the Linear Algebra Lab

So this week's lectures were on trees, a topic I found to be confusing mostly because I cannot think of any reason that one would use such a datatype... that is if it is a datatype. My biggest issue with them is that they can only have sub-elements which are also trees or None. The way we analyzed them, traced through them and defined properties and methods for them were fairly straight forward and really the main point was to realize what the appropriate base case should be. The recursive algorithm to trace though all nodes was simple as well. Trees, what are they good for?

The lab this week was the first time material I've already learned came up in computer science. Having completed linear algebra last semester made this lab easier as both me and my partner had previous knowledge of how vector multiplication worked and how matrix-vector multiplication worked. This lab also gave me some insight on how computers view matrices and vectors, as list objects. The lab also gave me some ideas on how I can apply what I have learned so far, for example try to come up with recursive and non-recursive functions that preform other matrix and vector operations that we learned in linear algebra.

Oh yeah... Assignment 1 was due this week. For me, most of it was easy and straightforward except part 5, which took me 2 days to do. I just kept getting a maximum recursion depth exceeded error, and eventually I figured it out. I was doing the silly thing of calling my function to move cheeses using four stools in my function to move cheeses using three stools, instead of having it call itself. After that was cleared up the rest came quickly. So how did you do, as in did you finish and attempt the bonus? Or were you too lazy to do it and just submitted it without it?

Saturday, 8 February 2014

Week 5 - Well What Did You Learn?

Not much new this week, with more tracing recursive algorithms. Well, we did learn about scope, basically where Python looks for pieces of code depending on how "accessible" they are. Code can either be restricted to a certain method or function, available locally or made global so that it is defined for the entire file. I suppose that's good to know, for whenever it comes up as well as for tracing code which has this hierarchy.

The lab this week was really useful, practicing coding recursively and going through the process of getting to the recursive insight. Once you understand it and struggle with it, you realize what to do and after that, it seems much easier. For instance, my partner and I spent the majority of the lab trying to do the first recursive code that we were supposed to come up with, tracing out test cases multiple times. After almost an hour, we figured out what we needed to do and got it working. We moved on to the second problem and solved it in under five minutes because it seemed so easy after having spent so much time thoroughly analyzing the code for the previous question.

As for Assignment 1, progress has been... slow. I find it hard to figure out how to implement some of the methods required and because of that I keep stopping after an hour, giving up. I know that the Towers of Hanoi code we analyzed will help sooner or later, but now it seems pointless. Well, how about you? What did you learn from this week's lectures and has it helped you at all?