Sunday, 16 February 2014

Trees!

This week in CSC148, the topic we covered was Trees. Trees are a very interesting data structure that is very useful in computer programming. It is made up of series of nodes which contain data. Nodes continually store data like branches in a tree until they reach the endpoint, which is the leaf. The leaf has no more children.

The Tree data structure uses a lot of what we previously learned. A big part of this is recursion. We use recursion a lot, especially when we are traversing through the tree. There are three types of traversal. Post, Pre and In order traversal. I find it very easy to differentiate between them by remembering that one is-
left top right, right top left and top left right. By using this it is easy to make the traversal be understood.

In other news, the midterm is coming up. I have to say, it is quite scary to think about it. I am particularly worried in forgetting the simple syntax that we learned. Usually when i code and forget about a specific function, I have the option in looking it up. If the English language is proving difficult to understand, I could always type it in the shell. In the test, I do not have this luxury. Therefore, for me, it might prove difficult.

Sunday, 9 February 2014

Tower of ...Cheese?

Well out of all the simulations that could've replaced rings in Towers of Hanoi, I don't understand why cheese was picked. Moving cheese around? Not very realistic. Even so it sounds interesting. The Tower of Hanoi is a famous math puzzle designed to help understand recursive solutions better. The last time this was explained to me, I( along with my group) were tasked to solving it using an iterative solution. By doing it recursively, it made things more interesting. Tower of Anne Hoy is almost exactly like Tower of Hanoi except with an extra stool. With this extra stool, solving it will be a bit more challenging.

The lab this week was also interesting. It was unlike other labs because the first few minutes were spent on tracing functions. I guess this was to brush up on our recursive functions but I thought it was too simple. The next parts of the lab were quite up to standard.

Next week we finally do trees. (Yay!) I am looking forward to it because I had trouble with it in the past. I used to think that values to the left are always smaller than the root and values to the right are always larger. I am not quite sure why I was under this impression but because of that, it made it difficult for me to visualize trees and the concept of them

Saturday, 1 February 2014

Inheriting recursively except when not

When we learned about inheritance and exceptions, I thought it was grade twelve all over again. Almost nothing has changed over the course of the year when it came to these topics in python. These problems are solved the exact same way as they were in Python 2.7, which I am quite familiar with. However, the first term of 108 was spent on very basic things(NOT Object Oriented) so inheritance was a good refreshing of memory. Because of such a long hiatus in using classes, I was quite pleased with the review of the syntax.

For me at least, recursion isn't exactly new either. That being said, the python language Danny is teaching is not too familiar to me and the extensive uses of list comprehension is quite extraordinary. Many examples were simple 1 line answers instead of the multiple nested loops that I'm used to. I guess this is being efficient, but pythonese is truly extraordinarily simple compared to the language of java. System.out.println was really a headache because of the lack of connection to the coder. Print(x) is much more simple and easy to understand as it shows a clear indication on what the code will do.

I had learned recursion in my previous year in high school as well. However, I did not put it into practice a lot since we were just mostly taught the theory behind it. It was nice to see a lot of practical uses that recursion had.

I am looking forward to next week's lectures where we hopefully continue learning about data structures, a more abstract view of computer science. I find this very interesting. I mean, recursion is cool and all but learning things the second time just isn't the same.