Friday, 3 April 2015

WEEK 12 - Final Impressions

Well, that's a wrap! This course has really been fascinating - from all of the topics discussed in lectures and labs, to all the assignments and term tests. The transition from CSC108 to CSC148 was quite drastic. Tons of information is presented right from the very beginning. In the first week of CSC108, we discussed integers, strings, and floats, whereas in CSC148 we started off talking about object-oriented programming.

This course provided many obstacles to overcome. The most challenging obstacle - and I think I can say this for everyone - were the assignments. I would spend countless hours on one method/function, and when I think it works, it fails or it causes another function to fail. Probably the most difficult assignment was the second assignment, particularly implementing the Minimax strategy. I didn't fully understand how Minimax worked until the day it was due, and I only finished it with a couple of hours to spare. As hard as the assignments were, they were also fun. The fact that we were able to create games and actually play them made the assignments much more entertaining.

Besides the assignments, learning about recursion was interesting. The idea of a function calling on itself in order to return a single value is pretty cool. This topic was then interwoven into tree, which was another interesting section. I had never guessed that date could be stored in trees.

In the end, this was a fantastic course taught by fantastic professors. I highly recommend this course to those who have no knowledge about computer science because you learn a lot of  great things hat may be useful later on in life. This has been a semester and now on to the final exam! Best wishes to everyone!

Thursday, 2 April 2015

WEEK 11 - Revisitation

Compared to my original thoughts on Week 7/8 post, I think my views on trees and binary trees have changed for the better. I originally thought that tracing and implementing recursive code was difficult. However, after doing Assignment #2 and working on Assignment #3, it is becoming easier to work with a tree. All of the practice that I have gained since learning about trees has given me a better understanding of how to work around problem and implement a proper solution. Similar to Nadine's post, I also now realize that linked lists are not that difficult to deal with. The professors' suggestion of drawing diagrams of the linked lists really does help. The diagrams helped me understand what the function was meant to do, as well as what node had to be looked at/mutated. Like with trees, all the lab exercises provided a lot of practice and insight on how to approach linked lists.

Wednesday, 1 April 2015

WEEK 10 - Binary Search Trees + Term Test 2

This week we discussed binary search trees. These are essentially binary tree that sort values into their respective spaces and used to increase search efficiency. All values less than the root are placed on the left most node, while values greater than the root are placed on the right most node.


The code used was almost identical with the code we used with a binary tree, expect that we implemented different functions (such as insert) that incorporated the property of a binary search tree. When coming up with the algorithm and writing the code, it was actually pretty easy to follow the steps and to trace it. Having knowledge about ordinary binary trees and traversing a tree, I was able to quickly understand the implementation.

Besides binary search trees, this week we also had our second term test. Overall, the test was......fair. It was a little more difficult than I expected, but it was not too difficult to think of a solution. I'm just hoping I passed and did decent. Wish me luck!

WEEK 9 - Linked Lists

This week we talked about linked lists and mutation. A linked list is somewhat like a tree, except that each node has a branching factor of 1, almost like a tree with a single branch. With these special type of lists, we explored a property that ordinary lists possess - mutability. Mutability refers to the ability to change a value. Elements of a lists can be mutated, but strings, for example, cannot be mutated.

(Note: Instead of 'head' we simply called it 'front', and the last node was called 'back'.)

When we began to implement methods, things became a little complicated. We first created a class called LLNode, which represented each node of a linked list. Each LLNode had attributes of the current value and the next value. We then created a LinkedList class, which had the methods of mutation. The algorithm and tracing of these methods was pretty difficult. The professor suggested that we draw pictures of the linked list to visualize the mutation occurring. This really helped me understand what each method was doing. Also, each method did not involve recursion, which is what we have been using with our tree methods. Instead, we were simply iterating over the linked list, much like we do with an ordinary list.

Thursday, 26 March 2015

WEEK 7+8 - Trees and Binary Trees

I haven't been blogging much with all of my assignments and test, so starting with this post, I'm going to try to cover 4 weeks of sLOGs in one week....



For two weeks, we discussed trees. Tree are categorized as an abstract data-type as it can hold several pieces of data. Each tree has one root and the root may or may not branch into multiple nodes/children (depending on the maximum number of branches it can hold; arity/branching factor). If a node has no branches, it is considered a leaf. This explanation may seem simple enough, but it gets more complicated. Implementing methods of a tree requires a lot of recursion. It took me quite some time to trace through the codes in class to figure out what was going on.

After coming back from' reading' week (more like 'sleeping-eating-working-eating-sleeping' week), we were introduced to a new type of tree: binary tree. As you can probably tell from the term, binary trees only have a branching factor of 2. The picture above is an example of a binary tree. After tracing tons and tons of recursion with regular trees, binary trees were fairly straightforward.

Honestly, if I paid more attention in lecture, all of this content would have been easy, but all I was focusing on during this time was Assignment #2. We spent almost an entire class talking about it, particularly Minimax. I was only able to complete Minimax within 2 hours before the deadline thanks to office hours. I'm not even sure how I did on everything else. I hope for the best.

Thursday, 19 February 2015

WEEK 6 - Object-Oriented Programming (OOP) Summary

(Note: this will be my topic for Week 7)

YOU DOWN WITH O-O-P? YEAH YOU KNOW ME!

As you can probably guess from above, this week we will discuss Object-Oriented Programming. First off, what is Object-Oriented Programming? Object-Oriented Programming, or OOP, is a concept in which objects are the initial concern. We then use these objects and manipulate them to our needs. OOP has been the primary focus of this course so far.



OOP contains a multitude of concepts. Some of the concepts we covered in this course were creating classes and methods, initializing instance variables, and inheritance. All of these topics were discussed in my Week 4 entry, if you want a more detailed analysis of these topics.

Overall, these concepts were rather easy to grasp. The majority of these concepts, such as classes and methods, were explained in CSC108, so that really helped. With OOP down, I can't wait to begin the next sections of this course.

Monday, 9 February 2015

WEEK 5 - Tracing Recursion + Term Test 1

I know I'm a little late, but better late than never!

This week, we were instructed to discuss about tracing recursion from Week 4. Recursion essentially involves repeating the entire function until each element of the input is reached. If you have ever experienced recursive functions in math, that's exactly what it is - except that we view as Python instead of just mathematical symbols. I have to say, tracing recursive code was pretty simple. At first it was confusing, particularly with list nested in a list, which is nested within another list. However, after doing the examples in lecture and in lab, you start to pick up the format. It's especially helpful that we did not need to write down the function if we already figured out what it does for a certain input. For instance, if we figured out what a function did with a non-list, we would just write the output and skip all the elementary steps. This kept the solution very clean. As well, if the docstring is not given, you can also tell what the function does by simply tracing it and/or picking up the pattern. Overall, with practice, recursion becomes quite simple and actually fun! I can't wait until we learn how to write recursive functions.

Besides tracing recursive codes, we had our first term test. The test was fairly straightforward. It was much like what we had done in lecture and in our labs exercises. This made extremely happy. The test also involved tracing recursion, which also made me shriek inside. We're getting our results this week and I'm hoping that I did well. Wish me luck!

Sunday, 1 February 2015

WEEK 4 - First Impressions

Well, I guess you can say that these first weeks were a little hectic - mainly because our first assignment was due this week. Before I get to talking about the assignment, I should probably discuss the material we covered so far.

The first week was essentially a review of the last weeks of CSC108. We looked at the construction of classes, which was straightforward. The second week of class was when we began to look at new topics. While I was familiar with the method __str__, we learned the difference between __str__ and __repr__. Both are very similar as both return string values. However, we learned __str__ returns a string version of self, while __repr__ returns a string representation of self which evaluates to itself. We then talked about Abstract Data Types (ADTs), which include lists, dictionaries, and stacks. As far as we're concerned, we do not necessarily focus on the implementation of these ADTs, but rather what they return and how we call them. The same week we looked at privatizing variables and functions. We do this by adding an underscore ('_') in front of the variable/function. This was completely new to me and surprising as I thought that all code was privatized. To end the week, we looked at another topic that was discussed in CSC108 which was unittests. As you can see, the pace picked up in the second week. The third week was all about inheritance, raising exceptions, and list comprehensions. Inheritance is essentially creating a superclass and giving all its attributes to a subclass. Raising exceptions allowed us to inform users whether they have done something wrong, such as raising a NotImplementedError. As for list comprehensions, we were basically taught about a for loop that is used for lists and can be written in just one line, which is very useful. If you want the topics in detail, I suggest referring to Timothy's sLOG. It is well detailed and quite amusing. In the end, all of these topics came together for Assignment 1.

Honestly, I found the first assignment very overwhelming. We were given the assignment early on in the semester and once I opened it, a boat load of information came hurling towards me, but I picked out the information that was related to the assignment and found it reasonable (as I thought). I thought I could get it done in the first week, but I realized that I needed to learn new material. Even with the new material we learned, the assignment was very challenging. The information provided was very abstract and ambiguous, which I found odd since CSC165 was all about precision. We were given the opportunity to do whatever we needed to do as long as we met the requirements. This was fairly stressful since I was usually given starter code in CSC108. All of these factors attributed to the difficulty in completing this assignment, However, after rereading (and rereading and rereading) the assignment, going on Piazza, and visiting office hours, a lot of key information was given and specified a lot of confusion I, and the majority of people, had.

Wednesday, 21 January 2015

WEEK 3 - Why Geeks Should Write

Finally! CSC148 has arrived! Our first entry for our sLOGs is to write about why 'geeks' should write. When presented with this topic, I thought this topic was specifically about writing in a computer language, but it referred to writing in English. It was kind of awkward posting my first entry about why people should write in Python, Java, C++, etc. instead of English, so I apologize for any confusion to anyone who had read my first post. As for the intended topic, it was rather difficult for me to think of reasons why writing in English is important, but then I read Joel Spolsky's blog entry.

One area of importance that I learned in CSC165 was critical thinking and logical reasoning. These attributes were greatly emphasized when approaching proofs. However, you can write a bunch of steps down to prove a statement, but each step would mean almost nothing. The main focus of the proofs was the reasoning behind each step. This leads us into the other important area of CSC165 - more generally, computer science - communication.

Writing is important for geeks because it allows us to communicate to our fellow peers about our ideas for new programs or on improving one. Writing also allows you to explain your reasoning behind each line. Without these explanations, like proofs in CSC165, the line of code almost has no meaning. Lastly, writing in English gives people the opportunity to understand how the program is supposed to be functioned. All of these reasons are not only essential to computer science, but in everything. Communication shows great knowledge and understanding in what you are doing.

Advice for Computer Science College Students (Joel Spolsky):
http://www.joelonsoftware.com/articles/CollegeAdvice.html