Saturday 26 October 2013

Week 6

Week 6 - the halfway point for the course! Coincidentally, because of Thanksgiving and the first midterm we didn't have any class for the week - just the midterm on Wednesday and lab #5/ exercise #4 on Friday. 

First off, let's talk about the midterm. It was a fair test, and covered recursion, classes/inheritance, and testing. I liked that the questions were varied as opposed to being along the lines of: 'write code for this function' each time, testing our understanding in different ways. I thought that the first question was interesting - it involved calculating the output for inputs 1-6 in the recursive function we had to write for assignment 1.  I thought that it was a good way to test the ability to read and understand how a recursive function works - except for the fact that those who went far enough in assignment 1 have already written the exact same function themselves, and that more time was spent doing simple arithmetic than thinking about the code. The rest of the questions were quite straightforward: writing a recursive function, implementing a subclass of list, and writing 3 possible tests to test our subclass. Overall, I enjoyed writing the first midterm.

The exercise this week was about tree traversal, and was a good way to keep the concept of trees fresh in our mind in preparation for linked lists the following week. Since we only touched on trees rather quickly during week 5, it was a good opportunity to review the code for the different tree traversals, as well as get some practice writing recursive functions for trees.

The lab provided a good comparison of the efficiency of three different ways of iterating: for loops, list comprehensions, and generators. I remember when I first started learning Python that one of the first problem sets involved a problem very similar to the pythagorean triples function in the lab. It was a struggle back then, but I never realized how simple the solution could be with list comprehensions/generators. Finally, one last thing I learned this week was the any() built in function - something I wish I knew about sooner!

Next week we'll be covering some new and important material (link lists) so I'm looking forward to that next.

No comments:

Post a Comment