Sunday, March 15, 2015

Sunday March 15th, 2015

In the past weeks we have completed both assignment 2 and term test 2. I found assignment 2 to be pretty difficult, especially with trying to implement strategy minimax. I think that I understood the idea of the strategy and the approach that we were supposed to use, but I still struggled heavily with implementing it. Danny did post something on the piazza page that summarized what we had to do, so I ended up following that. Hopefully, I can find out what I did right/wrong but I guess we will have to wait and see until the strike ends.

As for term test 2, I thought it was a very fair test. The three questions that were asked covered the three main things we have talked about in class since the last test: traversing through trees, binary search trees, and linked lists. Once again, we will have to wait until the strike is over in order to get our marks since there are no TAs who will mark them.

I think that the idea of linked lists is very interesting. A linked list is, when you look at it from the bigger picture, a list of objects that are nodes and are connected in a sequence. This means that every object has a current value and a next value, and that next value has a current value and next value, and so on. The list itself only has instance variables front, back, and size. That means in order to access objects within the list, you have to walk through the list by constantly looking at each node's next value, and that next value's next value (I hope that makes sense to whoever is reading this). The back instance variable's next value refers to None, since it is the end of the list. Also, the linked list has a size, depending on how many objects are in between the front and back. This is a very interesting concept to me, but I do not really understand a practical reason for sorting objects in this manner. Perhaps we will figure out in the coming weeks.

We are about to begin the third week of the strike, and I really hope it ends soon. We have not had any labs which I really value towards my learning, especially in this course. Labs are where I get to work with my partner and TA and practice the material that we have learned in lecture. Working on the labs alone at home is a lot more difficult, so hopefully we can all get back in those labs soon and do some computer science! :)

Tuesday, March 3, 2015

Tuesday, March 3rd, 2015

So I talked about using recursion to go through trees 2 posts ago, but I have not talked about recursion specifically. So in this post, I will talk about the deceivingly beautiful concept of recursion.

Three weeks ago, I was not sure how I felt about recursion. I was very uncomfortable with the concept of it and was not sure if I would ever learn to become accustomed to it. However, as the weeks went by, I began to realize how useful it can be for solving problems. I mean, creating a function that calls itself in the body is honestly mind-blowing. I like to think of it as function-ception (a function inside of a function, for those who have not seen the amazing film Inception (2010)).

A recursive function is a function that calls itself. Any function that uses recursion can also be created by using iteration. However, recursion makes the function concise and better looking, where as iteration can make the function long, complicated, and ugly for other computer scientists to read. In order to ensure that recursion will work, you must figure out a base case (for example, k = 0) and find out if you can solve the base case of your problem. If it works, you can increment the base case value (ie. take k = 0 + 1, so k = 1) and see if it still works. Eventually, your function will work for any case (ie. k >= 0) and you can assume it will work for all cases. Thus, recursion is your friend here. This concept of seeing if the function works for a base case, and then incrementing is called induction. In short, creating a function that calls itself, (ie. a recursive function) makes solving problems in computer science a whole lot easier.

We have been using recursion for the past 3 weeks in class and in labs which have both been very helpful for my understanding. Writing recursive code can get a little tricky for myself but working on the lab exercises with my partner has also been helpful. Unfortunately, labs may get cancelled this week due to the TAs strike that is going at this very moment. Hopefully it ends soon so that I can continue going to labs and develop my understand of recursion and computer science!