Thursday, 27 February 2014

Recursion slog

Recursion can seem strange or confusing at first, but once it is understood, it can be quite useful. Recursion is essentially a repetition within a function where the function calls itself. This is generally used to break up the process of solving a problem into easier steps or for clarity purposes. It is used when the problem has a sub-problem which repeats the format of the problem in one way or another. Instead of typing up the same code again to solve this sub-problem, the function would be called within itself so that this sub-problem is treated as if it were the main problem. A good way to understand this process is tracing. Some examples of problems with similar formatted sub-problems are loops, nested lists, and Trees. Also, the Tower of Hanoi problem is  a good example. The pattern here is that these examples have repetitions within themselves, similar to recursion, which is why recursion is so useful. To add to this, since recursion has the ability to  infinitely repeat itself, an important piece to stopping this is a base case, where the function and or recursion continues until the base case is met.

Tuesday, 4 February 2014

week 4




  •  I learned that you can use recursion to solve smaller problems, and that a function can call itself. 
  • Does this mean the function defines itself before you finish writing the code?
  • I thought that fractal were interesting, with the ability to draw something. I thought it was interesting that a fractal was like recursion in the fact that it can call itself, to be defined and can  have image(s) on both sides, that are similar to itself. I find it interesting that it almost is a visual of recursion along with this theme of repetition.
  • The part about drawing koch fractal starting at order 3, using smaller orders confused me because of the multiple lines each order produces with the addition of placing those smaller orders in one large picture. I had to re-read this part and go through it looking at the image then the "instruction", and almost imagine the construction of the drawing in my head. I started to understand this better also when I traced it.
  • Recursion and fibonaccis sequence reminds me of when I learned it in high school calculus as well as induction, which I learned in university math.
  • the part on recursive directories and files confused me, I will re-read this again through the week to gain a better understanding
  • the pygame part was hard to understand, but was interesting in terms of the real world application for creating a visual object or playing around with it, which was fun 
  • I'm going to try the exercises because I understand most of the things that were said on recursion, but the questions including drawing a shape looks like they would better enhance my understanding of fractal and the exercises in general look like they would allow me to better grasp these topics
  • I learned that recursive definitions are useful for expressing complex data structures
  • I found it interesting and potentially helpful when learning this new way or organizing what test cases to use although I think I have a general understanding for test cases, from csc108
  • I want to review the unit test part to make sure I properly have an understanding of it
  • I learned that you need base case in recursion (function), so it can tell the computer and or code when to stop