Monday, 17 February 2014

Week 6

Week 6

This week in class, we went over trees. The terminology was straightforward and seemed logical (for example: root, leaf, node, path, length). How to write code that visits every element in the tree, called a traversal, was also reviewed. There were three types, pre-order, in-order, and post-order traversal, and each involved recursion. In addition, various methods for a tree class were introduced.

Outside of class, the thing I worked on this week were the lab and assignment 1. This lab involved list comprehensions as well writing some unit test cases. I remember that in the last time I had to do this, in a previous lab, I forgot how to do it and was a little confused. But this time, when I looked at the examples from the previous lab, the process was much more clear to me. The other part, converting list comprehensions to for loops, went okay. The other main thing this week was assignment 1. Although I thought I had finished it last week, I figured out that I could make some major improvements to what I had. This mainly applies to step five, which solves the Towers of Anne Hoy game for four stools in the most efficient way (hopefully). What I originally had matched the most efficient known method for up to nine cheeses. Starting with the tenth cheese, my method took more moves. By twenty cheeses, my method was using more than double of the best known method. (I found this out by looking at other people's posts on Piazza). To make matters worse, I did not see all this until February 13 at around 4:30-5:00 P.M. Luckily, I had about 5 hours to fix my code. After several failed attempts, I did figure out something that I believe produces the same number of moves as the best known solution for any number of cheeses (not just up to nine like my old method) with a few hours to spare. With assignment one out of the way, I guess now the thing to do is study for the midterm and start A2!


The first SLOG I randomly picked today is http://csc148minimalist.tumblr.com/. After reading this SLOG, I (and probably many people) can relate to this person in the aspect of “drifting in and out of classes in a zombie-like fashion” and hoping that this class would help ease me into the new semester. I do agree with this person in that the first lab was harder than I expected, and like I mentioned in a previous log, the directions were a little confusing. This person also makes a comment about CSC 108 being ego boosting, which I thought was funny. The second SLOG is http://heapofcode.blogspot.ca/. The first thing that stood out on this SLOG is the person's first entry title (with the def __init__), which I thought was creative. I also liked how this person tried to sound enthusiastic, and how he/she mentioned Pokemon in the Object Oriented Programming log because I happen to have a bunch of Pokemon toys that bring some very sweet memories back to me :)

No comments:

Post a Comment