Thursday, 2 April 2015

Final Thoughts, Concerns, and Achievements!

It's finally the end of the semester!! It's been a long journey through my first year of university and it's a bit scary to think about how quickly it went by. I've learned a lot both academically and otherwise.

As for what I've learned in this class specifically and my general thoughts on it... I have to say there are quite a lot of things.

First off, some thoughts on the final topic(s) of the course : efficiency and big-oh.

The last topic of the course discussing efficiency and big-oh in terms of how quickly it would take a piece of code to execute. While several basic categories were mentions, a few were highlighted in class or used in most of the examples. These included constant time - where the run time doesn't not depend on n at all, linear time - where the run time depended on n linearly, quadratic (or polynomial time in general) - where the run time depended on n quadratic-ly (or to whatever polynomial degree), and logarithmic time - where the run time depended on n relative to log base 2. We practiced in class how to analyse code and determine how long relative to n the code would take to run. I felt that this was fairly easy to understand compared to recursion some of the other topics.

Over the course of the semester I learned various things about computer science, my interests, and feel as though I have stressed and panicked over error messages while also feeling very accomplished when things worked! I have to say... computer science and this area is not my cup of tea. While I did find it challenging and some of the topics interesting, as a whole, I can't say I 'enjoyed' the class and would consider pursuing it in the future. I initially took it to open the door to studies in artificial intelligence (as I want to study Cognitive Science) but have decided ultimately that computer science is not for me. However, even though I am deciding not to continue studies in computer science, I do feel that this course taught me several things that will be helpful in the future :)

And so, with this... it's time to say farewell to this slog! Actually I take that back... I'll say goodbye after the exam at the end of the month XD

Revisiting Recursion

It's been several weeks and even months since I was first introduced to the concept of recursion and at the time it was simply tracing recursion; I wasn't at the level to start writing recursive functions yet. However, since then much time has passed and we've had a lot of practice with recursion in lab exercises, lecture, and of course with Assignment 3 which is due soon. Most of Option B in Assignment 3 is writing recursive functions and with all the practice we've done with it, I do feel /fairly/ comfortable with it although I am still a bit shakey on the topic with certain types of questions but I hope that by the time I finish Assignment 3, I will have improved on those aspects! It's been a long time and I've come a long way since when I was first introduced to recursion and said the following: 'I can see how useful these type of functions would be extremely useful but I can't imagine writing one at this point...' :)

I've also taken a read through several other sloggers' posts on their thoughts on recursion and was relieved to discover that I wasn't the only one still not entirely comfortable with recursion. We've all improved and learned a lot however to say that I (and maybe we?) have mastered recursion would be an overstatement.

Linked -> Lists and Term Test 2

Linked lists were discussed that week and I this concept must easier to understand than previous concepts. This is probably due to the fact that there is a linear progression - one node in an item in a linked list only points to one other item and not several like in a tree. This attribute of linked lists made it much easier to understand however I didn't really see the practicality of it at the time unlike with trees. It's practicality however became evident during a question on the second term test. One of the questions on the term test represented a path down a tree as a linked list and I found it very clear to understand exactly what was going on!

Speaking of the term test, this test was a lot better than the previous one because I actually took advantage of the aid sheet and it helped me catch a stupid mistake that I could have made. For the question where we had to transverse the given tree in a particular order, I had misread the questions and transversed it in the wrong order at first until I was double checking the notes on my aid sheet and my answer. Good thing I caught that! Phew.

Edit: this post contained my impressions of week 8 and 9 combined....oops

Wednesday, 1 April 2015

Binary Search Trees!

Binary search trees are different from regular binary trees in that they are already sorted - everything thing to the left of a node is smaller than the node and everything to the right of the node is larger than the node. This makes searching through a binary search tree much more efficient since the maximum number of checks the program would have to go through is the height of the tree. This would occur if the program reaches the bottom of the tree and still hasn't found the value it's looking for.

Also, different tree traversals were discussed in class: pre order, post order and in order.

Pre order visits the node itself before visiting the left node in pre order and then finally visiting the right node pre order.

Post order visits the left and right nodes in post order first (in that order - left then right) before visiting the node itself last.

In order visits the left node in order first and then visits the node itself before finally visiting the right node in order.

It was quite confusing at first transversing trees in a particular pattern but after some practice it proved to be quite simple in actuality!

Object Oriented Programming Summary

Object Oriented Programming Summary

Superclasses
Superclasses (or sometimes called parent classes) are generic classes that very broad methods that may need to be implemented in a subclass (this is often the case). Superclasses act like an umbrella in that depending on what the superclass is, many subclasses could fall under the umbrella of the superclass. For example, if I were to create a program for organizing or creating poetry, the superclass would be a generalized Poetry superclass and its sublclasses would be the different types of poetry (eg, haiku, limerick, sonnet, etc).

Subclasses
Subclassas are more specific classes under a superclass. They have all the attributes of the superclass they are a part of but have more specific information and functions contained within it than the superclass. Going back to the poetry example, the superclass Poetry would have various methods which would not be able to be implemented because the superclass lacks information since it's too general. Let's take the example of having a method that checks the rhyme scheme of a the poetry type. The method cannot be implemented in the superclass since the rhyme scheme of different poetry types is different. However it can be implemented in the subclass where the rhyme scheme of that particular poetry type is defined.

Inheritance
Inhertence is an important element of OOP. It allows for information to be passed from a superclass to its subclasses. When a subclass is created, it will inherited all aspects of the superclass and will have access to all of its methods. When writing methods of the subclass that are present in the superclass, the variables and attributes that are defined need to be stated and if you don't want to inherit a variable, it must be intialized in the code of that method otherwise it will produce an error (learned from personal experience...). However, the number of parameters in the subclass must match the number in the superclass or else once again, an error will arise.

For me, understanding inheritence and how to write the code in a subclass and determining what was inheriteed and what wasn't was difficult. In some cases, there were subclasses where almost nothing in certain methods was inherited and in others, almost everything was inherited aside from a few specific elements. But in the process of playing around with superclasses and subclasses and from working on Assignment 1, I gradually got the hang of it.



Wednesday, 4 February 2015

Recursion Tracing

Learning about recursion for the first time last week was quite interesting actually -functions that call themselves? Sounded bizarre at first but with the sum_list function tracing problems practiced in class, it became quite clear how it worked. Tracing with the simple example presented in class was clear and I thought I had a firm grasp on the concept but with some of the functions in lab 3 and the question on today's test, my confidence wavered a bit as it took longer to figure out what the function should do and how much I should unpack it with every line. I do feel my confidence growing again though the more I practice tracing these types on functions. I can see how useful these type of functions would be extremely useful but I can't imagine writing one at this point...

Tuesday, 3 February 2015

Impressions (and Frustrations) Thus Far

Ending of week 4 and heading into week 5, I'd say it's a good time to backtrack a little on the situation so far. 

Several elements have been covered so far including writing classes and subclass (of which there was a more than slightly frustrating assignment on, but I'll talk about that later, tracing recursive functions, and characteristics and methods of stacks. Most of the topics have been fairly straight forward with examples provided in class but there were a few aspects that remained blurry until it was necessary to implement them in the assignment. Specifically, the purpose and implementation of the __repr__() method. As it was absolutely necessary to implement this function in every class we wrote for the assignment, pushing off understanding it simply wasn't an option. After going over class notes, google-ing, and asking classmates, I finally figured out how to implement the method and was able to finish the rough bulk work for the assignment (yay~), that is, until the dreaded error messages starting appearing when I ran the program to test it......

Saturday, 24 January 2015

Why Geeks Should Write

geek [\ˈgēk\] noun - typically used to describe a person who is very interested in and knowledgeable about a particular topic (may or may not be socially awkward)

In this particular case, geeks refers to the mysterious species seen typing away at a computer for several hours at a time except to make the occasional pained/frustrated/desperate cry followed by a moment of apparent lifelessness. Yes, that's right - geeks in this slog will refer to us computer scientists who know the pain of not being able to figure out the minuscule bug showering them with error messages. 

Now for many living the geek life, the digital world of 0's and 1's and command lines is more than enough. However, being able to write is also an important aspect of computer science that needs to be practiced and valued. Below are three good reasons good writing would benefit computer science geeks:

1) Writing will improve communication with others - In the event that the geek ventures beyond the virtual world and into society (perhaps to boast about the program they just spend several tens of hours on), good communication skills are necessary for clear communication. Writing is an effective way of practicing how to express thoughts and ideas clearly and precisely.

2) Writing will help clarify new concepts into understandable lingo - Often times, concepts in any field are presented in language particular to that field making it more than slightly confusing at times. Writing about such new concepts in regular words will allow for deeper understanding of the concept and will in the process will reveal exactly what is unclear about the new concept. This will make finding and fixing the point of confusion that much easier when the error messages start appearing.

3) Writing will allow for more efficient programming - Continuing from the previous point, be able to write about the program and what it should do will help make the coding process easier. Being able to solve a problem in an understandable language first will make for easier coding as it will just be a translation process of converting regular language into geek language.