Thursday, February 20, 2014

Week 7 Recursion

Week 7 Recursion


Recursion was the main focus what we have been studying for the past two weeks. Recursion is mainly using the solution from the smaller instance of the problems to solve the problem as a whole using the same process until the program gets to some point. The formal explanation would be that recursion is functions that call themselves within their definitions.It is one of the most important idea in computer science that help to build the models of functions. It is a circular idea of solving problems through looping over the same strategy and solve the small instances of the problem. That is to say, break down the questions into smaller part that is easier to calculate; after that, combine all the answers together and stop at some given point. It is an extremely helpful method that calls itself repeatedly within the function. Tree models are the best examples for recursion which runs recursively. Similarly, the Fibonacci numbers in math uses the same method as recursion in programming. It is quite obvious that all the recursion look like tree figures, including the examples of tree models, turtle and Fibonacci numbers. One of the most important point in recursion is to find the smallest instance to start the recursion, and the other one is to find an end point for it to stop recursion. Sometimes, it is hard to find the start point, yet as long as we can find out the start point, then the whole process would be straight forward. 

Thursday, February 13, 2014

week 6

This week, we continued to do the recursion, which still seems a bit complicated for me. I worked on A1 a lot this week, but I still did not get a good solution for the function move_cheese. I plan to study recursion more during reading week. Using a tree to interpret recursion is actually easier even though there are different cases, but graphs always help to understand the topics. The week after reading week will be the mid term for this course yet I still don't really understand the most important part of it. This week's lab is pretty easy and the program can be used for the calculation in MAT223, which is really fun.

Thursday, February 6, 2014

week 5 post

This week we still stick on the topic of recursion, on Monday we tried to trace some recursions by hand which helped me to understand the process how haoni works even though i haven't look at the assignment yet. I have a pretty good idea on how the recursion works, yet I am still confused about how to write the recursion statements in a line of return. I tried hard during the lab yet I still cannot get a solution based on a line doing it, I end up with a for loop which we did in 108, much easier >.<. For the staff we learned on Wednesday, I found it hard to trace and I did poorly on understanding the 'global' and 'nonlocal' thing. I have no idea why the result changes from 'test spam' to "nonlocal spam" even though several people explained to me, I still cannot understand it. I believe the reason why I cannot understand it is because I did not fully understand recursion. I will go up to the website of python and read the docs to make sure I understand it. Then, I will try to finish my A1 as soon as possible cause there is not much time left. The Haoni thing is really fun though, which seems random yet involves a lot of math and sequences.