Thursday, April 2, 2015

Last Impressions (Week 12)

It felt like time went by faster this semester compared to the last. All of my classes are now over and the only thing left in this school year are exams and 2 essays. My overall impression of this course was that the concepts of trees and recursions were very interesting. I wasn't really interested at the stuff we learned at the beginning and at the end, which were something to do with functions vs methods and big-Oh. I would say that while big-Oh intrigued me in CSC165, I guess I got tired of it by now.

What was particularly interesting about this course was that all 3 assignments were very closely connected. At the start of the course, when I heard that each assignment would build on the next one, one thought that crossed my mind was whether everyone would have to always have the same partners for all 3 assignments then. When assignment 2 came out, it turned out that starter code for a completed assignment 1 was given. So it turned out what I believed was false. Nonetheless, I worked with the same people for all 3 assignments. Option A of assignment 3 actually relied on a portion of assignment 2, the minimax strategy class. My group decided to avoid option A primarily because of two reasons. For one, we thought our minimax wasn't working perfectly, and the other reason was because it seemed much more complicated. Using the unit test in lab09, it turned out that our minimax was actually working fine and so the problem that we were encountering had to be in our tippy game state class. While working on option B, we were glad to have been provided with all the function headers and docstrings, unlike the previous assignment.

One of the biggest hurdle in this class for me was wrapping my head around the concept of recursion. It took me a week or two after being introduced to recursion to finally get what was going on. At the start I managed to implement recursive functions just fine following the steps we did for the sum_list function. But during the lab, when we got some more complicated recursive functions, I felt myself lost for the first time in any of my computer science course. In all previous scenarios, when an extremely difficult problem came up, I was able to solve it after some time, trying out different approaches. However, for these recursive functions that would have more than just I if-else statement, I found myself giving up before the lab even finished. It wasn't until working on assignment 2 with my friends that I was able to properly understand how to implement more complex recursive functions. I am glad that I got back to it even after having initially given up on it.

While in 12 weeks, it seemed like this course did not cover as many topics as CSC108, I felt that the focus on about 2-3 particular topics like recursion really worked well to tie together all of the tests and assignments. I enjoyed this course.

Friday, March 27, 2015

Revisiting an Earlier Post (Week 11)

This week, I will revisit my Slog from Week 4. During Week 4, we were to write about our impressions of the first 3 weeks. In that post, I complained about how about half of each class was getting devoted to answering student questions regarding the first assignment. I agree that it is certainly a bit annoying to use most of class time to answer similar questions that were asked on Piazza. However, I also disagree to certain aspects of it. For both assignment 2 and 3, I have found the questions and answers to be much more helpful, especially when the professor includes slides to help answer common questions asked on Piazza. I suppose my original stance on this was different because I was not very into assignment 1. My group started assignment 1 late and it was generally simple. However, as the concepts gets more complex, assistance like this in class is no doubt helpful.

In Slog #9 by theCStist, they write about how they used to write code by trying a bunch of different things until it ended up working but now they take it step by step, starting with some examples. I find that this is basically what I was initially doing for the more complex recursive functions. I admit that sometimes I still do this. However, when the code does run, I try to go over the completed code and add comments to describe what I did there to help myself understand what I just did.


Saturday, March 21, 2015

Impressions of Week 9 (Week 10)

Last week, we wrote our second term test. I found the test to be straightforward and average in difficulty. Like before, studying the lab exercises and especially the additional exercises proves to be one of the most useful thing one can do in preparing for these tests. One thing I really didn't like was that the test took place so early at 9am for Diane's section.
During this week, we learned about mutating binary search trees. Although we got a short lab for it, I didn't bother doing it until after the test. And even after the test, it wasn't until week 10 that I really attempted it. Without having a lab to attend, doing these at home doesn't feel like it has much priority.

In this post, Jason writes that handwriting code is not a very good way of evaluating a student's skills in writing code as it results in a lot of careless mistakes. I agree that having tests be 100% hand written code is not the best way to evaluate people and in many cases, typing code does not directly translate into being able to hand write the code. Thus, when preparing for tests like these, students including myself will have to find alternate ways to prepare for the test including writing a bunch of practice code by hand. However, I find that it may be difficult to find an alternative to this as allowing students to write code on a computer will easily allow cheating. Furthermore, it would force every student to bring a laptop or the professors would have to somehow provide hundreds of computers, both of which are unrealistic scenarios.

Friday, March 13, 2015

Impressions of Week 8 [Linked Lists] (Week 9)

I found the idea of linked list to be a bit more easy to wrap my head around than the trees from the previous weeks. Mainly because it's linear, in the sense that the data do not keep spreading out. The data in a linked list is similar to cargo in a freight train, each node contains some stuff then contains the link to the next node.
When I looked over the code of the already implemented functions in the lab, I noticed that many of them has a similar segment of code which is used to traverse through it. Seeing this, I went back to the lecture slides and found that there was a page on walking through a linked list. I guess I must have missed this slide during class. You walk through a linked list by having a variable cur_node  refer to the front. Then in a while loop structure, we do some stuff then set cur_node to cur_node.nxt.
This was the first lab exercise that we didn't get a chance to go into tutorial and get assistance from a TA. Since I didn't have my lab on Thursday this week, I sort of slacked off on the lab exercise. Once I did get to it, I was able to implement a few functions without a problem but then I ran into trouble with insert_before and delete_after. After trying some random stuff, I gave up and looked through the solutions. Although the solutions did help, I felt like I would have understood more if I was able to work through it myself after some feedback. However, I should probably only blame myself since I slacked off this week. I will try harder next week and refrain from blaming the strike for my lowered motivation to do lab work.

Sunday, March 8, 2015

Impressions of Week 7 [Binary Trees] (Week 8)

During week 7, we learned about linked structures, using the class BTNode as the example. A binary tree (BT) is subcategory of trees. While a root in a tree structure may have infinitely many childrens, all contained within a list, a root in a binary tree may have up to two children. One of the examples we examined that made use of a binary tree was binary arithmetic expressions. Each of its root contains a "data" that can be used to evaluate its two children. For example, a root with '+', left node '3', and right node '4' would represent '3+4'. A more complex case would require recursion. Such as one with a root '+', left node '*', right node '7'. The left node (now the root), has a left node '3' and right node '4'. In order for this binary tree to make sense, each child node that also has children must evaluate its children and return the evaluated value up the tree so that its parent may evaluate that value. Doing this we would represent the expression '(3*4)+7', with the '(3*4)' evaluated first and returned as the left node. The final evaluation would look like '12+7'.
I didn't really get what preorder, inorder, and postorder was about. I will try to review them in the future. I found the idea of binary search trees to be rather convenient and interesting.
The parenthesize function in the lab was almost identical to the evaluate function we developed in class. I actually found this to be helpful in solidifying my understanding of recursion using binary trees. I found list_between and list_internal_between to be extremely difficult. I ran out of time during the lab to finish it, and decided to give up on it for the time being.

Coming back to this, I finally figured out what I was doing wrong in list_between and list_internal_between. My biggest mistake was to trying to implement the else block in one line like I did for every other recursive function. This has expanded my view on implementing recursive functions. I had always tried to stick to a single line per if, elif, and else for recursion because recursively calling the function would reset any sort of setting, counters and the likes in the function.
Having learned this, I think that I should try more ways to implement recursive functions, even if I initially think they are wrong. If I try enough ways to implement one, I will learn something from it even if I fail to correctly implement it the first few times.

Sunday, March 1, 2015

Monday, February 16, 2015

Object-Orientated Programming Summary (Week 6)

Object-Orientated Programming (OOP) was the main focus of our first unit in this course. One of the features of OOP is inheritance. Inheritance allows us to be able to take and use methods from a previously written class rather than rewriting it all over again in a similar class. Suppose we made a Shape class which may have a method to get its area. Then we decide to create a Square class, which will have new attributes such as having defined side lengths. However, Square is certainly a Shape and also has an area. By having Square inherit Shape, we are able to use the previously established method to get the area from Shape in Square.

OOP allows us to organize our classes that are similar. For example, a Square and Triangle class both can be organized under an abstract class Square. We can define things that all shapes possess in Shape or at least lay out the foundation to be overwritten in one of its subclasses by implementing a NotImplementedError. Then we will define things specific to Square and Triangle in their own class. By having both of these classes inherit Shape, we can simplify our code by having other parts of our code work for generic Shape objects. Since Square and Triangle are both also Shape objects, any of code that works for Shape objects will work for them. Imagine making thousands of specific card classes for a card game. We would not want to implement code to deal with every single type of card classes. Instead, we can have every specific card class inherit a superclass Card then implement code to handle Card objects.

In inheritance, a subclass inherits methods and attributes from the superclass. It is then possible to extend a method from the superclass in the subclass by reusing the same code from it buy altering it in a way to better suit the subclass. It is also possible to completely override a method from the superclass by rewriting the whole method if a way to alter the original code to fit the new class is not readily available.

I thought the course's approach to teaching us OOP was okay. I generally found the examples to help me better understand what is going on when I decide to read over the course notes. I didn't really like how fast and rushed the first assignment felt. We were still going over many things involved in the assignment during class when it came out. In the end, my group ended up finishing the assignment during the last few days before it was due.

Saturday, February 7, 2015

Tracing Recursive Code (Week 5)

As I had said last week, recursion was a new subject to me. My computer science teacher in high school never even mentioned about recursion. The only thing that I knew about recursion at the start of this course was that Google search easter egg where if you search recursion it says "did you mean: recursion". Moving on, I find that recursion really makes code look simpler but a bit more complicated. I have noticed that all the recursive code that we have traced so far always includes an if structure. I wonder if it is possible to design a recursive function that doesn't use an if structure and doesn't run into an infinite loop.

Anyways, onto tracing recursive code. I didn't really understand the first recursion tracing handout that the professor gave in lecture. Well, I just simply followed along and wrote down whatever was on the screen. When lab03 came around, I decided not to bother with looking at it until the day of the lab. During the lab, I noticed how simple and similar the example tracing were to the first handout. I immediately used the first handout to help me complete the first few lab questions. The recursive code without proper docstrings weren't very different, since I don't always pay attention to docstrings anyways. Tracing these recursive code suddenly seemed so much easier. However, recursion still appears to me as simply a way to complicate and beautify code.

Also, that last question on implementing that length function using recursion was difficult for me. I tried all sorts of ways to do it but failed. Mainly, I was unable to compare the length of the current list to that of each sublists, thus I was only ever comparing the deepest sublists. I eventually gave up on it. It was probably the first time I ever gave up on completing a piece of code. I asked a friend to help explain it to me, which was very helpful. I will try harder next time.

Friday, January 30, 2015

Impressions of First Three Weeks (Week 4)

The transition from CSC108 to CSC148 was sort of smooth. This course picked up right where CSC108 left off, with classes and object orientated programming. The very first week's lectures reviewed constructing a class. The professor described the __init__ method more in-depth. I felt that the point.py example helped me get back into pace after the long holiday break. One thing that I noticed was that taking notes on paper for this course may not be as effective as for CSC108 and CSC148, since it is much more programming intensive. Since I did not want to haul around my laptop, I decided to continue through the course with paper and pencil. An approach I used was to take note of some important details of the examples given, then attempt them on my own time when I'm in front of my computer.

I was surprised by how early we got our first assignment in this course compared to my previous computer science courses. Apparently, we were able to complete the assignment with our knowledge from CSC108. However, I decided to wait a few more lectures before starting on it. This worked to my advantage since the professor gave us more hints and clarifications during each lecture. However, soon it seemed that at least half of the lecture time was devoted to answering student questions regarding the assignment. At first, some very important questions were answered, but it soon got to the point where the same questions are reiterated. In the end, the assignment went well.

We also talked about recursion during week 3. Unlike some people, I actually had no idea what recursion was until just now. It seemed weird to me that a function can call itself within itself. At first, I thought that this would just be a great way to run into infinite loops but the worksheet quickly dispelled that idea. By making use an if structure, the function can be defined to take care of all cases in an arbitrarily deeply nested list. After applying a few examples, recursion suddenly seemed easier.

Wednesday, January 21, 2015

Why Geeks Should Write (Week 3)

I personally believe that computer scientists, and everyone alike should be able to write and communicate in some form of human language. The ability to write not only allows one to formulate more coherent comments when coding but also allows one to properly communicate to their employers and employees and other people relevant to their project. It is rare to think that someone would be working on programs all alone throughout their entire lives, therefore communication is very important. Since we are computer scientists, we would definitely prefer communication using our computers. By being able to write properly, we can get our ideas and points across to people that are on the same project as us. It would be very difficult and tiresome to write code as a team if no one could understand what others are writing because they left out all the comments and docstrings.

Another reason computer scientists should write is because documenting one's work could be very important for future uses. Since we have such a limiting memory capacity, before long, we will forget things, even important things. To make sure we will never forget the most important things, we should write them down and perhaps store them inside computers, which have a much better memory than us. For when we wish to retrieve information about our projects years ago, we will always be able to access them.