Sunday, April 5, 2015

Week #12 (Mar. 30 - Apr. 2)

Finally, the last week of class. The good news is that the TA strike is finally over!

This week in class, we discussed efficiency and the big-oh notation.  Since it isn’t the first time I encountered efficiency and time complexity, I didn’t think I had trouble understanding most of the materials we talked about. All of the materials discussed I already learned in CSC165 and I think I have a good grasp of the concept. But more practice never hurts. Although, I was able to understand most of the materials, there are still some things that I don’t really get. That is, graph ADTs. I think the reason may be that I wasn’t paying much attention when the professor was talking about this topic. What I plan to do over the weekend is to read over the slide this week and try to understand as much from it as possible about graph ADTs.

Now that the strike is over, we got our test 2 back. When I saw my grade for test 2, the mark I got was quite unexpected. I thought I did quite well on the test, but the marks tell a different story. The portion that lost me the most marks was on linked lists. Before going into the test I thought that I had a good understanding of linked lists. I guess iterations and mutation of linked list should be what I need to focus on to study for the exam. As well as practice with recursion which I am still not all that comfortable with. There are a lot to study and to cover before the exam, fortunately the exam is still a few weeks away. Therefore, I still have some time to study and learn the materials that I didn’t understand and improve on them.

This concludes the last SLOG of CSC148, Bye! ╮( ̄▽ ̄)╭

Sunday, March 29, 2015

Looping Back.

As we are nearing the end of the year, I look back at some of the things that I’ve learned over the course of this term. Some particular concepts I want to discuss is still on the concept of recursion. The SLOG I want to discuss is the week that assignment 2 was due (Week #8). Back then when my group members and I was finishing up on our assignments, at a point we were stuck on implementing minimax. We just could figure out how to start on it. If I recall correctly, that week was also the week where we worked on recursive methods on binary trees. In the beginning of that lab, my partner and I was also stuck on implementing the recursive methods for the trees. However, towards the end of the lab, we were able to figure out some of the solutions to the lab, at least sufficient enough to do the quiz. But at the end, I still wasn’t confident on thinking recursively and I also wasn’t sure if at the end I did the quiz correctly or not. Going back to the day before assignment 2 was due, my group members worked tirelessly trying to get minimax to work, and thankfully at the end we were able to figure it out. Recalling back to my earlier self, it is understandable how I often get stuck on recursion. I think this is a mindset that I will need to develop as I go through more and more of this course and into my career of being a computer scientist. Even as I work on assignment 3 recently, I get stuck on some of the recursive thinking of the assignment.

I looked through some other SLOGs created by my peers, Ruowen (http://csc148slogruowengao.blogspot.ca/) in her first interactions with recursion, she was also quite overwhelmed and challenged by it. Similar to me, my suggestion to her would be to have more practice on recursive thinking and writing recursive functions. As I said before, I believe recursion is a mindset, which is crucial in the careers of a computer sciences. Furthermore, some other things that I can do to make recursive thinking “easier” would be drawing pictures of what you think the function should do. Mentioned by Wenzheng (http://1024forbidden.blogspot.ca/) I’ve tried to draw out the recursive process of a function, and I have to say, drawing it out sometimes can make this a lot easier. Problems encountered by Wenzheng and I can relate out is sometimes it may be hard to figure out what the base case of a recursive function should be. What we both agree on is to have more practice writing recursive functions and thinking recursively.

Yay, strike finally over! 

Sunday, March 22, 2015

Week #10 (Mar. 16 - 20)

With the continuation of the TA strike, tutorials and labs are still cancels, hopefully it will resolve soon. Though technically we still don’t have labs anymore, we are still responsible for the materials covered in the labs. But due to my laziness, I still have got myself to get working on the labs yet. I might use some of the time over the weekend to work through the labs myself. With this being the third week of the TA strike, I start to wonder what will happen to the marks that are acquired to attending the tutorials and labs. 

This week in lecture, we went back to BSTs (Binary Search Tree). We explored through the steps required to change a BST, for example, if we were to trying to add an element to the binary search tree what steps are required to complete this method? We know that a binary search tree has a property of having elements whose value is less than its current value on the left of the tree and values which is larger than the current value in the current node on the right of the tree. Knowing this, we are able to write a recursive method that compares the value being added to the value of the current node and to its children nodes until there is no more comparison to be made and add the value to the BST at the right position. The other method of BST we implemented in class was delete, this method allows us to delete a node from the BST. It gets complicated when the node we are deleting is not a leaf, which requires us to replace the deleted node who is not a leaf with the right most leaf of the left subtree or the left most leaf of the right subtree. The algorithm of this method is a bit long, therefore the professor recommends us to write out an implementation comment whenever we encounter problems that requires multiple steps to solve the problem. I thinking that writing an implementation comment is quite useful because I usually don't have the incentive to write the comments before i finish writing the code, and having the algorithm of the code written down before I start implementing it could be helpful in keeping my mind clear on the objective. I will definitely  try to develop the habit of writing comments on what I need to implement before I actually implement the code. At the end, I was able to understand the examples that we discussed in lectures and I hope I am able to work through the problems in labs.

Sunday, March 15, 2015

Week #9 (Mar. 9 - 13)

Unfortunately, the strike couldn’t be averted. So, there goes all of the tutorials and labs this week. But what is good is that at least assignment 2 is over. My partner and I struggled on implementing minimax for a couple of days in the week and we haven’t been able to get it working until Wednesday night. The problem that we were stuck on was that we don’t know when exactly to multiply the score by -1.0 and what do to with that score when we got it. Thankfully, by the end of the night we were able to think it through. We were supposed to multiply the score we get back from the recursive code by -1.0 since the score we were calculating is the current player’s opponent’s score. After getting the score, we can just use the move that produce the highest score from the list of possible moves.

This week, we were introduced to linked list. A linked list has a front, a back and a size. The front of a linked list is the first item in a linked list. Similarly, the back is the last item of a linked list and the size is just the number of items in that linked list. Each linked list node has two attributes, a value and the next linked list node that it is referring to. If a linked list has a size greater than two, then it must have a value connected or linked to the current node. For example, a linked list; 1 -> 2 -> 3 -> 4 -> 5 -> | has a size of 5, the front of the list is 1 and the back of the list is 5. The next linked list node from the front is 2 and the next linked list node from the value 5 is None, which signifies the end of a linked list. We also discussed iterations through the values of the linked list and mutating its data. At first, it was quite confusing to me since there are so many things to keep track of while tracing the code, similar to recursion. But after completing this week’s lab exercises, I was able to get a better understanding of linked lists and looping and changing them.


In the end, I wish that the strike will end soon, because it is affecting a lot of my course, especially the language course that I am taking. Since the instructor of that course is part of the union, all classes are cancelled.

Saturday, March 7, 2015

Week #8 (Mar. 2 - 6)

This week we are introduced to another abstract data type (ADT). Binary Trees are pretty much the same as trees, except for that binary trees have an arity of 2. This means that binary trees have a maximum of two branches. So then, we can name those two branches as the left branch and the right branch. I think with these settle, we can now introduce binary search trees, which are also binary trees but the difference all of the values at the left branch is smaller than the root, whereas the value at the right branch of the tree is greater than the value at the root. So now when we want to search if a binary tree contains a value we can just check if the value that we are looking for is greater, smaller or equal to the value at the current node. We can keep doing this until we are at the end of the tree or we found the value we are looking for. I believe that is will be more efficient because that we don’t have visit all of the nodes of a binary tree. Let say if the value we are looking for is 6 and the value at the root is 10, then we just look into the left branch of 10 since 6 is smaller than 10 and according to the properties of a binary search tree, all values that is smaller than the value at the root will be in the left child of the root. So this avoids looking through all of the tree for the value, thus speeding up the process of looking for a value.

In the lab that week, we worked on recursive codes around binary trees and binary search trees. During the first half of the lab, my partner and I was quite stuck on some of the problems, we had no idea to retrieve the data from the trees. However, nearing the end of the lab, we were able to figure out that the recursive code to the problem and get things working.  After getting the things straight, I felt that I was prepared for the quiz. At the end, I think I did okay on the quiz.


In addition, there is the assignment that was due the following week. Things were looking good so far for my group member and I as we finished up the game state and move for the game tippy, we tested out the game and the game was functioning normally. We plan to finish the up the rest of the assignment next week ( i.e., minimax). I hope things goes well.

Sunday, March 1, 2015

Object-Oriented Programing Again!?

Apparently, here is another SLOG about OOP. What is Object-Oriented Programming(OOP)? OOP is an programming model that focuses more on objects other than functions, and more around managing data then performing operations. I have touched a bit of OOP back in CSC108 as I mentioned before and through CSC148 I thinker the course enhanced my skills at OOP. 

So, what is related to OOP? To my understanding, OOP basically is writing classes that revolves around different objects and data. Usually, a class has attributes, which is something that every object of that same class must have, i.e., if I were writing a class on students, some attributes that the class student must have is, for example, a student number. Also, the class student may be inherited to a more specific class that do things (methods) only that specific class does. Another example, if I were to create another class called undergrad and this undergrad class that I am about to create has most of the same attribute as the class student. Now I can inherit everything from the class student to the class undergrad, and make undergrad a subclass of student. So now, everything instance, method, attribute that class student has, not class undergrad has those things too. I need not to repeat all of those again and begin writing from scratch. 

There are also methods that class has, which I think are functions that only the object of that class has. From our example class undergrad, it might has method to tell how many credits that the undergrad student has, also it might have a method that get the major that a object of the class undergrad is currently in. What I think how methods and functions are different is that methods need a class as a part of its parameter where as functions don’t usually require a class as a part of its parameter.


By writing classes, I believe that we are able to solve problems that relates more to our lives, i.e., from our example of keeping records of students.

Thursday, February 12, 2015

Object-Oriented Programming

Yet another week of hard work has ended. The good news is that next week is reading week.

For the past few weeks, most of our tutorials and lectures are focus on object-oriented programming. From a point of view of a student who has not touched a lot of programming and computer science before university, I can honestly say that I have learned at lot in the past weeks. Although I have touched a bit of object-oriented programming in CSC108, it is not enough for me to get through this course with just that. Some new concepts that was covered was knowing how to translate the question description into code. This part I struggle a bit at first in the beginning of the course, but as I move on to do more questions, I starts to get better at it. Also, we also learned how to write special methods for class such as __init__, __eq__, __str__, __repr__ and __contains__. Some of these special methods I learned in CSC108, so I had no problems writing them, though some of them I have know learn and understand such as __repr__ because when it was first shown to me, I did not know what is the use for __repr__. There is also something else that I found to be really important, which is know what to implement in the parent class and its children class. I have honestly say that in the process of writing assignment 1, I struggled quite a lot in deciding what to put in the parent class and its child class. Often times I would ask myself "what is the point of writing a generic class I could write most of them in one class". Later I understood that, writing a parent class makes it easier or more faster in implementing a new subclass for that superclass, since a parent class would contain everything a generic subclass would need, so I won't have to repeat everything if I have to write a similar class. Though object-oriented programming is essential, I found recursion to be more interesting. I cannot wait to learn more about recursion.

See you in a week.