For this past week I haven't been up to much CS on account of a significant pile of math homework. However, I still have had time to think about the midterm as well as recursion, a rather interesting topic.
The first time I had recursion explained to me, it was somewhat confusingly done with matryoshka dolls (those russian dolls made of wood, in increasing sizes where opening one reveals another). The second time was more concise: "A recursive function is one that calls itself." In a computer science context, this explanation made a lot more sense. Like induction, recursion calls for a base case: unlike induction however, it is more like a final stage instead of a first step. In this sense, recursion takes a large problem and continues to reduce it to a slightly smaller problem, until it reaches the base case and can be solved. There's a caveat to this however, a function which employs recursion may not be the most efficient, since it has to go through every previous case. In our Towers of Hanoi assignment, I certainly noticed this. Because of the degree to which Tour.py relied on recursion, its efficiency was rather questionable (this of course, may be a result of my inability to code efficiently but I'm going to attribute it to recursion for argument's sake). Despite this, recursion certainly makes the code easy to read and to understand, and it was really the only way I could think of to code the assignment.
In my experience with math, I've seen recursion come up in the definition of some very pretty fractal pictures, I'm even guilty of making a Menger Sponge cake (second iteration, made of many tiny delicious cake cubes held together by cream cheese icing). To learn about the use of recursion in CS has been very interesting for me. I can appreciate its usefulness very much.
I'm (not) looking forward to the midterm this coming week and I feel totally (not) prepared! Here's to NOT failing.
Saturday, 22 February 2014
Saturday, 15 February 2014
Week 6: Assignment 1 is DONE!
My main focus this past week has been working on finishing Assignment 1. Having completed TOAHModel.py and ConsoleController.py, I was left with the most interesting part of the problem: figuring out how I was going to code Tour.py and optimize my cheese stacking strategy. The most important step of this was, of course, figuring out a way to find the elusive i, the variable that optimizes the Towers of Hanoi for four stools. At first, I attempted to try to find some pattern, but then decided that my complete inability to do computations (perhaps inability is inaccurate, and a strong aversion is more correct) meant that a different solution was suited for me. I read a slog that has a computational solution to i that you can check out here: http://liamsslog.blogspot.ca/2014/02/week-5-tower-of-hanoi.html. In the end, I thought about how the simplest way to define the Fibonacci sequence is simply to define it recursively, and then proceeded to question why in the world I would define this sequence differently. I simply used the formula provided in the handout, and found the minimal number of moves for each number of cheeses. Then I returned the i that corresponded with that minimal number.
The next thing was to simply use the function provided in class for three cheeses to recursively define a function for four cheeses, as indicated by the handout. I ended up having an error that took an hour of time and a fresh pair of eyes to find, but in the end, my solution worked, and I had a still-not-yet-proven-optimal solution for four stools. This was followed by coding the bonus, which took a lot less long than I thought. Finally, I submitted Assignment 1 to MarkUs for the final time on February twelfth.
Labs this week flew by faster than I can say. My partner and I finished within an hour and I do think I am improving in terms of my familiarity with recursion and my abilities to use it correctly.
Class this week was regarding trees. I'm quite excited about this, since graph theory is one of my mathematical favourites. I'm not sure that my experience with König's lemma and Aronszajn trees will really help me in this class, but I look forward to this coming chapter of CSC148. On the other hand, I feel slightly unprepared for the midterm, seeing as I haven't gotten any information regarding its contents, but I'm hoping that more information will come up during this week so that I will have time to fully ready myself.
The next thing was to simply use the function provided in class for three cheeses to recursively define a function for four cheeses, as indicated by the handout. I ended up having an error that took an hour of time and a fresh pair of eyes to find, but in the end, my solution worked, and I had a still-not-yet-proven-optimal solution for four stools. This was followed by coding the bonus, which took a lot less long than I thought. Finally, I submitted Assignment 1 to MarkUs for the final time on February twelfth.
Labs this week flew by faster than I can say. My partner and I finished within an hour and I do think I am improving in terms of my familiarity with recursion and my abilities to use it correctly.
Class this week was regarding trees. I'm quite excited about this, since graph theory is one of my mathematical favourites. I'm not sure that my experience with König's lemma and Aronszajn trees will really help me in this class, but I look forward to this coming chapter of CSC148. On the other hand, I feel slightly unprepared for the midterm, seeing as I haven't gotten any information regarding its contents, but I'm hoping that more information will come up during this week so that I will have time to fully ready myself.
Saturday, 8 February 2014
Week 5: Assignment 1 and More Recursion!
During the past week, I've learnt a great deal on programming recursion! I found it quite fluid and intuitive and I think I have math to thank for that. The labs especially I felt were constructive, but not difficult and that the examples we went through during those two hours really solidified my understanding. As usual, the posted course materials provided excellent examples that were also very useful. If you want to see a nice explanation of a great example of recursion, check out this slog post: http://siyangcsc148w3.blogspot.ca/2014/01/some-thoughts-on-recursion.html!
The rest of my focus this week, has been mainly directed towards assignment 1 and all it's glory. I remember in the fifth grade, I had a computer game and one of the mini-games within that game was exactly the Towers of Hanoi but with large wooden crates instead of cheeses. I've also have a friend who had been to a math colloquium regarding the open problem of the optimization of the fourth peg, and who discussed the presentation with me. I found it was a lot of fun to think about this familiar topic. I am near completion for this assignment and I think I'm making good progress.
I would like to mention a few of my difficulties with this assignment. The first being that at the beginning, the instructions felt quite random. Upon seeing the TOAHModel.py file presented, I was confused as to what I had to write and what was written for me. It felt like the instructions were presented in a jumble that I had to slowly sort through and that the corrections appearing via email and piazza were difficult to keep track of. After many errors and much rereading and rewriting, I now have a working TOAHModel.py file as well as a well working ConsoleController.py file. I'm quite pleased with my progress this week and I look forward to completing this assignment. All this being said, I am now desperately craving a nice Gruyère.
The rest of my focus this week, has been mainly directed towards assignment 1 and all it's glory. I remember in the fifth grade, I had a computer game and one of the mini-games within that game was exactly the Towers of Hanoi but with large wooden crates instead of cheeses. I've also have a friend who had been to a math colloquium regarding the open problem of the optimization of the fourth peg, and who discussed the presentation with me. I found it was a lot of fun to think about this familiar topic. I am near completion for this assignment and I think I'm making good progress.
I would like to mention a few of my difficulties with this assignment. The first being that at the beginning, the instructions felt quite random. Upon seeing the TOAHModel.py file presented, I was confused as to what I had to write and what was written for me. It felt like the instructions were presented in a jumble that I had to slowly sort through and that the corrections appearing via email and piazza were difficult to keep track of. After many errors and much rereading and rewriting, I now have a working TOAHModel.py file as well as a well working ConsoleController.py file. I'm quite pleased with my progress this week and I look forward to completing this assignment. All this being said, I am now desperately craving a nice Gruyère.
Subscribe to:
Posts (Atom)