Wednesday, 1 April 2015

8: Week's 9 BST and Midterm II

During the ninth week of our CSC148 course, our second midterm was coming up. I did fairly well on my first midterm and I hoped to do just as well. Unfortunately, that was not the case. I spent a great deal of my time on the third question only to realize that I had been incorrectly writing my code. My code would return a list instead of return NoneType. Therefore, I spent about 20 minutes of my 60 minute exam on something absolutely pointless. I quickly scratched it all off and rewrote the proper code on the back of the question paper. Luckily, I had enough time to finish it and I was still able to confidently answer the first two questions with many less mistakes. The first questions were rather straight-forward and simple for me; they were basic comprehension questions on trees and their lengths. The second question, on the other hand, was slightly more difficult and the third question was even worse. I feel as though the biggest difficulty factor for this midterm was not the questions but was the time, instead. With only sixty minutes to answer all the questions, there was barely any room for error.

On a side note, during the week, we learned about Binary Search Trees (BSTs) and how they are very efficient when it comes to search for a number amongst all of the nodes. The assumptions in the BSTs (smaller numbers to the left and larger numbers to the right), allows the programmer to drastically cut his search time by not needing to visit every single node in the tree. For example, take this tree (rotated 90 degrees counter clockwise):
         12
      10
5        9
   2
      1

In this case, 5 has kids 2 and 10; 10 has kids 12 and 9 and 2 has only 1 as a child. If a function was search for the number 12, the function would have to visit every node before it until it finally reaches it. (for example, 5 -> 2 -> 1 -> 10 -> 9 -> 12, of course it depends on which order it is done in) On the other hand, using a BST, the function already knows that 12 is larger than 5 and so immediately goes into the right subtree where the root is 10. It then repeats and goes to the right subtree of 10 because 12 is larger than 10 and thus reaches its target value.

If it already makes a considerable difference, you can just imagine how much difference a BST makes when used in such a larger scale.

Tuesday, 24 March 2015

7: Week 8, A2 & Linked Lists

As week 8 came to end, we had to hand in the second assignment and we also learned about linked lists. We handed in our second assignment after a lot of hard team work on it. Our team, composed of three people, were able to grasp the concept of the minimax strategy though our implementation could use a bit more work. We didn't quite understand the need of having rough_outcome but it seems that will come in useful in the third assignment; I hope to do well in that one as well.

We learned about linked lists in class today, which is an extremely simple concept, frankly. If the information stored were to be people, it would be as if each person were to memorize who's in front of them (or alternatively, who's behind them). It's a rather simple concept but manipulating a linked list, such as changing an object or the order, or even searching for an object, is quite the opposite. When trying to change the list, you need to keep track of a lot information, such as who is in front, who is in the back and what position you are in, to name a few. Frankly, despite its complexity, I still believe I am able to comfortably handle and manipulate linked lists without many complications. Oh and the strike is still on.

Thanks!

Tuesday, 17 March 2015

6: Week 7, Nodes and Trees

So as week 7 came to an end, our lectures have only just grasped the basic concepts of binary trees.

The root of the tree is an object (a number, a string, anything) and is called a node. That node has the option of having children, in which the children are also nodes. If a node does not have children, the node is considered to be a leaf. Nodes that are not the root, the very first node in a tree, and have children  are named internal nodes. This week, we were introduced to the concepts of binary trees. In binary trees, all inetrnal nodes have exactly two children and all nodes are not empty. We also learned about binary search trees, in which all nodes represent a number. The child to the left of the node (conveniently named the left subtree) is smaller than the node and, similarly, the child on the right of the node is larger than the node. For example, if we have the values 2, 4, and 6; if 4 is the node, then 2 would be the child to the left and 6 would be the child to the right. If 6 was the node instead, the 4 would be to the left of the 6 and the 2 would be to the left of the 4. Here is a small example of a Binary Search Tree:
This allows the programmer to easily search through nodes as it allows them to cut their search times exponentially as it is not necessary to go through all the values.
The concept is easy and simple to grasp and it seems, from the SLOGs I've read, no one else had any problems understanding it.

Oh and the strike is still on.

Sunday, 8 March 2015

5. Recursive Recursion

It seems as though recursion is going to be a recursive theme in my SLOGs.

*sigh*

Seeing as we just completed the second assignment, I realize that recursion is not as simple as I thought it was. Despite our team's struggles we were still able to get together and work through a solution. Our minimax strategy code worked great for subtract square but it struggled when it came to playing tippy. We believe our code for recursion was well written and it could not have been possible had it not been for the strategy we used in our many lectures and labs. One of which is to have two cases; one which is simple enough to not require recursion and one which needs recursion to properly solve it. For the first simple case, we simply write an if statement which would apply for it but not for the more complex case. As for the recursive case, we write an else statement which takes advantage of recursion and uses the incomplete function to complete it (if you know what I mean).

On the other hand, fellow SLOGer Antiaromatic pointed out that recursion problems can be seen as "trees" and I completely agree with them. Though at times it might not be necessary to literally make a tree to use recursion, having a multiple-depth list in a tree-like manner can work just as well.

Oh and our TAs are on strike.

Saturday, 21 February 2015

4: Object-Oriented Programming and Me!

So far, I feel as though Object-Oriented programming is both simple but complex. The idea and the thoughts are very straight-forward and logical, but when it comes to application, the code itself can seem quite odd. For example, when I needed to trace the execution of a queue function in our tutorial, what I thought would be the logical correct answer is not. Once I see my mistakes, I understand it and wont commit it again but I remain slightly uncomfortable with the idea; similar to accepting the idea that 2+2 = 5. You may be able to do it when it comes to applying it but it does not feel right or logical.
My mistake was in the order of which the objects are inserted, for example, let's take Q = [1, [2, 3], 4]. From what I understood, the function adds the first value 1 to the queue, then adds the value 4, then 2 and finally 3. This makes no sense to me, I imagined it would add 1 first and then dive into the second list and add 2, then 3, exit the list and add 4. In order to understand what happens better, I'm going to have to insert the queue function into the python visualizer to fully understand and see how the computer is taking and storing information in queues.

On a side note, I feel I did very well on the midterm and average on the first assignment. I hope to raise my grade in the next assignment and do just as well on the next midterm and, hopefully, the finals, too.

See you soon!

Thursday, 12 February 2015

3: Recursion. meh, I guess.

So in the 5th week we focused on the idea of recursion and how to trace a function that uses recursion. The concept to me, seemed a bit complicated at the start but it made sense after the first trace. Recursion is rather simple from what I understand; it's like using a helper function in a function, but the helper function is the same function as the one you're writing.

Weird... right?

We had to trace a couple of recursion functions on the midterm and it's rather simple; it's as though you follow the function line by line, as if you're the computer reading the program. From what I've seen, several people found recursion to be an odd and abstract concept but I feel like it's a rather simple idea. I didn't think it was possible but now I'm wondering how I lived without it...

Monday, 2 February 2015

2: Is it a bird? No, is it a plane? No, it's Superclass!

A couple of weeks ago we introduced the concept of superclass and we needed to integrate it into our very first assignment. I had a group of two other programmers and I think we worked together surprisingly well. Together we were able to work through the toughest parts of the assignments and avoid missing small but important details. We had finished our first draft of the assignment with two classes. Luckily, one of our professors mentioned that there should be five and, together,  we were able to make changes to the program on time in order to get the best grade possible. I was satisfied with my part in the group and I felt as though we all contributed a great amount of effort into it. I'm anxious to see what grade we'll receive. In terms of the concept of a superclass, I feel as though I have thoroughly grasped it and demonstrated my knowledge in the first lab we had.

Sunday, 25 January 2015

1: Why geeks should know how to write

In this week's slog, we were assigned a specific topic. We must elaborate why geeks should know how to write.

But first, before we dive into the answer, we must learn more about what the question  is expecting from us. The word 'geek', to me, is a person who is obsessed with science fiction or information and technology. In reality, according to the Oxford dictionary, geek is an unfashionable or socially inept person, or a knowledgeable and obsessive enthusiast (http://www.oxforddictionaries.com/us/definition/american_english/geek). In order to avoid any ambiguity, I decided to write a paragraph on both. To begin with, why unfashionable or socially inept persons should write.

A person who is socially inept cannot properly express themselves while socializing and speaking to others. This prevents them from properly transmitting their ideas and their thoughts to others efficiently, leading to awkward interactions and embarrassment for the geek. In consequence, a geek is less likely to attempt to socialize or orally express themselves to others to avoid such awkward interactions. Everyone should be allowed to express themselves to someone or, at the very least, some thing. Diaries, journals and blogs allow people who aren't orally skilled to express themselves or elaborate and talk about their ideas. This not only allows the geek to be able to speak his mind and feel free to prevent types of depressions or loneliness but it also allows others who want to speak to the geek to interact with him. Commenting on his blog, trading emails or sending letters allows the geek to fully express himself in writing to others while avoiding awkward interactions due to a lack of socializing skill. If a geek cannot write then he cannot be free.

On the other hand, for the knowledgeable and obsessive enthusiast. If scientists, inventors and scholars were not able to clearly write down their ideas in a journal or diary, we would have never discovered some of the most amazing minds of the human race. Examples would include Isaac Newton's legendary "PhilosophiƦ Naturalis Principia Mathematica", which, according to the French mathematical physicist Alexis Clairaut, "marked the great epoch of a great revolution in physics." Another example would include the many notebooks that Leonardo da Vinci has written. Had these great minds not known how to write, these books could have never been written and, in consequence, could have completely changed the advancement of technology and our understanding for the world in our modern-day society.

In summary, geeks knowing how to write does not only benefit them, but can benefit the world entirely.

Thursday, 22 January 2015

Welcome to my SLOG

Welcome to the best time of your life.

This is my Course log (SLOG) for my introdocution to computer science course, CSC148. This SLOG will have weekly updates throughout my entire winter term. It allows me to express my struggles and my strengths to my professor, TAs, classmates and, most importantly, to myself. As the semester progresses, I will be looking through my previous posts to see how well I've improved as well as looking rhough other students' SLOGs to allow me to, not only help myself, but help others.
If I show that I'm struggling to comprehend a key notion or idea please do not hesitate to leave a comment, I will surely return the favour.

Thanks for reading and I hope you'll follow me through my weekly updates and I'll be sure to keep them interesting.