Sunday, 16 February 2014

Week 6: Trees and Finishing Up the Assignment

    The course material cover for week 6 was about a new type of data structure: binary trees. From what I remember, I have seen this during last week's lab. Binary trees are consisted of nodes and edges. When there are many nodes, those nodes become special. Each node can be seen as a root and some of them have children (maximum of two) and each child could also have children too. A node with no children is called a leaf. Some more definitions were covered in class.

    During the lectures, I was shown two implementations of binary trees. One used nested list, just like from the past lab. the 0-th element in the list is the node and the next two were the children. If there were no children, NoneType was in those places, otherwise it was another list. The second was basically the same except it was just a tree, meaning there could be any number of children, and we created trees objects.

    Because my partner and I were tired from mid-terms of other classes, we did not try much on the lab exercises. However, I though this weeks lab was quite easy. We had not much of a problem changing list comprehension to creating lists in the old/traditional way.

Sunday, 9 February 2014

Week 5: Start of the First Assignment

    This week, Danny showed the class his code for solving the original Tower of Hanoi problem. After seeing this, even though I did not start on the assignment, I had somewhat of an idea what to do for the assignment. Later this week, I started on the assignment and was able to pretty much finish the whole thing. However, knowing that I had a few mid-term exams coming up next week, I did not take much time making sure I did everything perfectly, without any bugs. I guess I have to do the nasty works later.

    Also in the lecture, scopes and namespaces were introduced. To be honest, I was late for class and missed most of the talks. The lecture slides did not really help me because there does not seem to have much explanations. Over the weekends, or maybe during the reading week, I should definitely find some online materials to read and study.

    The lab was focused on recursion. My partner and I had to traced some codes given certain inputs. Also, we had to write a recursive function, having to do with nested lists. The function that we made failed the test case that we created and a lot of time was spent trying to find what was wrong. We knew that our idea/approach was correct but something must have been faulty because computers don't lie. It turns out we had to put 'return' on the recursive call. Other than that, this week was an easy going one.

Sunday, 2 February 2014

Week 4: A Typical Week

    The lectures from this week focused mostly on showing examples of use of recursions and understanding them. Tracing a recursive function seems like a detective work, trying to narrow down and find the starting point, the base case. Recursion, although a simple concept, is still mind-boggling to me. I am afraid that given a problem, I may not notice the existence of a solution involving recursion. 

   This week's exercises were pretty simple and I am pretty confident on creating exception classes by inheritance and raising them when necessary. I can feel that in the future, raising exceptions will become very important if I want to make a program that does not mislead the user by spitting out a flawed output, when given an undesired input. I feel it is the programmer's fault when the computer program does not check whether its input is good or bad.

    The lab went fine except for writing unit tests. To be honest, despite learning about them from before, I have never written a unit test until that day. I had a difficult time coming up with good test cases and also had to do a fair bit of reading and googling in order to properly code. My partner and I had a little disagreement about what fuel economy represented, but it turned out the description was in the handout. I guess the lesson here is that I should read the handouts carefully, not skipping over words and fooling myself that I understand what I am suppose to do. 

    We were able to finish every thing except for writing the unit tests. I better start practicing creating unit tests. Our classes from the lab seems to do what were asked to do and the visual representation of the codes are clean. But I wonder if our approach was the best. I am guessing there are multiple ways of writing programs that ultimately does the same thing. Although I am not a fan of following conventions and thinking that a certain way of doing things is the best, since I am dealing with computer science, unfortunately, these things matter. Because of this, I think sharing codes amongst classmates, after everyone is done with their labs/exercises/assignment, of course, is a great way to learn from each other, seeing how one could have come up with simpler and more efficient piece of program. I hope this kind of learning is implemented in the near future.