Saturday, 4 April 2015

Last impressions (Week 12 SLOG)

Finally, we arrive at the end of CSC148. Looking back at the beginning of the course, I never thought I'd be able to tackle some of the tasks given in the assignment and tests. I remember being daunted by the concept of Python classes in my first lecture, and how the first assignment had no starter code, unlike all previous CSC108 assignments. Those concepts and problems seem trivial now. As the course went by, I found that the freedom in CSC148 allowed me to develop my own coding style, and allowed me to critically think about how a number of functions and methods can come together for one single purpose. Recursion was a big part of the course, and still a tough concept; however, identifying the base cases and careful thinking can unravel some of its mysteries. Not only did we write recursive code, we also saw how recursion can be used to improve efficiency. Tree traversal can often be a long procedure. If we use recursion to "remember" traversed subtrees and their values, we can greatly reduce the time it takes to search for something in a tree. We also looked at recursive data types such as linked lists. Linked lists are unique in that they have instance variables for the front and back node. While I still need time to tinker with linked lists in order to fully understand it, I was shown in lecture that they are not simply an arbitrary class to help CSC148 students with recursive thinking. We were shown its applications in improving the Queue function. Using linked lists, we were able to remove the dependence of n on Queue. In the end, CSC148 was a challenging course for me, as I have very little prior knowledge of programming or computer science in general. However, I am glad that I stuck through the course, as I gained invaluable experience and insight into the field.

Sunday, 29 March 2015

Review an Old SLOG (Week 11 SLOG)

Ah recursion, we meet again. I seem to enjoy writing about this topic, so I shall do so again for this week's entry. Looking back at what seems like an eternity (but truly only 5 weeks!), I can see that I have gained a deeper understanding of recursion. Although the very basic examples of recursive code can be written in a few lines, they do not fully represent the ability of this powerful idea. When I first started tracing recursive code, I never thought that it could be used to represent a type of artificial intelligence. In the assignments, I was surprised that a relatively strong A.I. could be made using recursion. However, the run time proved to be an issue in some code where a large amount of permutations was possible. In our final assignment, we were given an option to explore various ways of improving the efficiency of our recursive minimax code. I agree with myself in the past where I believed that recursion would be a strong tool. Although thinking about it can make my head hurt sometimes, trusting the code seems to help untangle the mess that tracing can sometimes cause. Looking at other classmates' SLOGS, they seem to have issues with tracing as well. The problem with losing track of where you are in your code is a prevalent issue among our class.

Saturday, 21 March 2015

Impressions on Modifying BSTrees (Week 10 SLOG)

Last week we revisited an idea that we had just touched upon: binary search trees. As I had wrote about before, these trees are unique in that each internal node has a maximum arity of two, the data in the nodes are comparable, and the data in the left node is always less than the data in the parent node, while the data in the right node is always greater than the data in the parent node. This specific structure must be conserved when we add or delete nodes from the tree. On the one hand, because humans can view the entire tree in a single instance, we can easily make decisions on which node should go where when modifications occur. Computers, on the other hand, follow a more linear path and can only look at one node at a time, therefore an algorithm must be made for different situations. For example, the algorithm for deleting a node has 5 different scenarios that must be accounted for. I agree with Heap that a good way to go about writing these solutions is to write out what you want your code to do in plain English first. Write comments as often as you can to explain what your code is doing, so that in the future others can understand your code as well. Ultimately, whatever you write in English can be expressed in code.

Saturday, 14 March 2015

Impressions on Linked Data Types (Week 9 SLOG)

Unfortunately, due to the T.A. strike, we had no labs this week, so I had less help than normal with understanding linked lists. However, I still had the chance to go over the lab handout and work on the problems a bit by myself. The idea of a "wrapper" was new and caused some trouble initially. It seemed normal to make a separate class to hold all the linked lists elements, but I found it odd that the wrapper only had variables that referenced the front and back of a linked list. This initially caused me confusion when doing certain tasks such as finding whether a linked list contains a specific object, as I would not know how to access those LLNodes between the front and the back nodes. To solve this problem, I would have to "walk the list," as Heap mentioned; that is, to make reference to the front node, and while a certain condition is satisfied, have that node reference the next one instead. We also worked with mutating a linked list structure, in which the order of actions is very important. In the append example, we were shown that we must change the last values nxt variable first, and then add a node as the back, otherwise we lose the old back node. These linked lists were new to me and I will most likely need to revisit them and tinker with the code once things get settled down over the next few weeks.

Thursday, 5 March 2015

Impressions of recursive data types (Week 8 SLOG)

Last week, we looked at a different type of tree called a binary tree, where each node only has two children. In some ways, the binary tree is simpler than a standard tree, as we can assign variables to the left child and right child, rather than finding a desired node through indexing. Not only does this make writing recursive code slightly easier (in my opinion), but it is also less mind-twisting to think about (again, in my opinion). Additionally, we looked at a type of binary tree called a binary search tree, where the left child node is always less than the current node, and the right child node is always greater than the current node. This makes searching for a particular node much more efficient, as you can effectively reduce your search time in half with the first iteration. In lab 6, we looked at implementing functions using a binary tree. Some of these functions proved to be more challenging as the conditions for desired results were usually more numerous than past exercises. Careful implementation and meticulous testing seem to be vital in order to write functions for these trees, binary search trees in particular.

Thursday, 26 February 2015

Week 7 SLOG

Please mark my Summary of Object Oriented Programming (Week 6 SLOG)

Friday, 13 February 2015

Summary of Object Oriented Programming (Week 6 SLOG)

In the past six weeks I feel that I have gained a decent understanding of classes and basic recursion. Creating our own classes help us solve some problems that would be difficult using only the default python classes. What's interesting about python is that every object stems from the object class, and thus inherit certain methods from it. Even though we can create our own objects (such as different types) de nouveau, they can share a number of properties with other python types. In fact, I learned that we can represent many different problems such as registries, games, and even antiquated mathematical operations using classes. The use of subclasses allows the already flexible idea of objects to fit a greater number of problems. Inherited values and methods allow subclasses have their own identity, while still being related to their parent classes in a way. While completing my assignment, I came across the idea of polymorphism: calling the same method but having it perform different operations. It appeared in my Strategy Class, where I called a method that carried out a move based on the currently chosen strategy. Since the methods had the same name, I could call it in a loop, while only changing the state of the current player's turn. Polymorphism spared me writing additional unnecessary code, and I can see it being a powerful tool.

Speaking of powerful tools, recursion seems to help us solve problems in areas where linear or looped code may have trouble. Not only is it powerful, it is also relatively simple code, with only a base case that is called on the most simple case, and a general case for more complicated arguments. However, these general cases may not always be so simple. In lab 6, I discovered that the general case may span some lines in order to cover every case and achieve the desired result. I think I worry too much about the code executing properly; some days I may attempt to trace out relatively complicated recursive code, sometimes resulting in more confusion. I found that if I just trust that the code will execute properly, I can work with a clearer mind. Interestingly, I have been seeing recursion more and more in my daily life. As a hobby, I enjoy learning about things that sound contradictory to common sense. I learned about fractals a few years ago, but I did not realize that they are based on recursion. Learning about object oriented programming has increased my appreciation for the natural world.

Friday, 6 February 2015

Tracing Recursion (Week 5 SLOG)

When first introduced to recursion, I found the concept very interesting. It sounded almost contradictory, in fact, that one could call a function containing the very same function in its body. I can imagine many cases where recursive code could look very simply, but tracing it would require a lot of brainpower. While the code we were required to trace in lab and on the midterm were fairly simple, I occasionally found myself making small mistakes such as forgetting to add 1 somewhere. It is helpful to note down which types of examples one has already traced, so that one can plug in its formula for an output in a more complicated recursion example. I guess the beauty in recursion is that it looks simple, but can tackle a multitude of problems that would have given us great trouble otherwise.

Saturday, 31 January 2015

First Impressions (Week 4 SLOG)

CSC148 picked up right where CSC108 left off: designing our own classes. At first, it was intimidating sitting in a room full of prospecting computer science majors. I had started my first university year with little to no programming experience, and here I was among students who have been coding since high school. While it was daunting at first, eventually my nerves were set to ease when our professor began the lecture. He is an entertaining man, although I will admit I sometimes get lost in the computer science jargon. In CSC148 I know I have to focus hard because I do not have a natural talent for programming. "My program is life sciences," I thought to myself, "what am I doing here?" Although I survived the first lecture, the first assignment left me initially baffled. Unlike CSC108, CSC148 allows for much more freedom. We are given a chance to develop our own programming style, as long as the final result meets the criteria. This was a big change that took me a few weeks to accept. Once I did however, completing the assignment went smoothly for the most part. 

In the labs, I felt that most of the work assigned was generally easy and helpful as a supplement to what we were learning in class. I am not fond of the lab quizzes however. Even though their content is similar to the lab activities, I feel that the allotted 15 minutes is barely sufficient. Also, the questions seem to be ambiguous at times. Perhaps this is another instance of the freedom CSC148 gives.

Though my initial impressions as a life sciences student left me wanting to drop the course, I think I'll persist through the semester. The content is challenging for me of course, because I have never seen anything like it. However, I feel that I am actually learning something and benefiting from my university experience. As of week 4, I am motivated to learn new ideas and I hope this feeling will persist to the end of the course (and perhaps begin again next year).

Thursday, 22 January 2015

Why Geeks Should Write

It is great to work alone, if one chooses to do so. There are no days when one has to walk out in the cold weather to meet up with a partner, and one does not have to go through the effort of deciphering a partner's work. Moreover, there is no chance of being paired with an unreliable partner, and no need to worry about your partner plagiarizing. However, there is much to be lost when working isolated. Communication between peers is key to being introduced to new ideas and to collaborate on problems. Being able to write effectively is just one aspect of communication. One may have decent ideas, but they may not reach their full potential without being conveyed effectively. In fact, the opposite could happen; terrible products may be presented to look appealing through witty language and charm. Effective writing is an important skill that I, an aspiring member of the workforce, believe everyone should possess.

For some reason, whenever the topic of writing papers comes up in daily conversation, many of my friends seem to wince in pain. Perhaps their reaction may be due to some bad experience in some English course in secondary school. I was no different at first. Had it not been for my English tutor, I would not have discovered the ease and joy of writing. Of course, there are certain rules and regulations a piece of writing must conform to; however, it is the deviation from those rules that I find most interesting, and ultimately most memorable. If everyone wrote the same 5 paragraph essay with an intro, 3 body paragraphs, and a conclusion, I would agree that writing can appear boring. However, if one can adapt and develop a personal style, the piece of writing will exhibit the true interesting characteristics of a person. This skill can only come from many hours of practice, as do many things. In the end, the rewards are worth the effort; being able to communicate with a high level of speech and writing may make one seem professional, responsible, and above all else, a good representation of a company.

Recently, I have been investing time rediscovering an old series of text-based video games. I can say that it is definitely the written plot that has brought me back to revisit these games. Good writing just seems to have that memorable effect on people.