Saturday, 28 March 2015

Revisiting Slog 2: Impressions of the first few weeks

Time seems to be flying at the speed of the light. It seems like it was just yesterday when I had begun this journey and it is already coming to an end. As I had wrote in my earlier post about my impressions of this class and semester in general, I expected a roller-coaster ride and that is exactly what I got. Those hectic weeks of back to back tests and assignments sure drained the life out of me but as long as everything pays off in the end, it was worth every penny. Wait penny is no longer in Canada, right? Anyways you guys get my reference. 

Looking back I recall writing about being extremely nervous about those turtle examples that Danny showed in his class. Looking back I realize that I have been worried for no reason at all. Then again that’s UofT for you, giving its students unnecessary stress. So expected. The reason I shouldn’t have worried about those turtle exercises is because they were never tests. Woot woot. Even then I am thoroughly impressed that with extra effort such as revisiting the lectures and asking my peers, I was actually able to come to an understanding. Even though it wasn’t tested I am glad that I do know how those examples work and I’m sure in future this knowledge may come in handy. You never know, I mean life is just so unpredictable. Who would have known that I would have enjoyed writing these slogs so much? At the beginning you can see how I was really unsure and surprised as to what I would write about, but now I feel that writing these slogs may have improved my writing skills especially my flow. 

Furthermore, I recall being nervous and excited about the transition from CSC108 and CSC148. The transition as I believed is not much difficult if one were to review the lecture notes and complete additional practise problems. I tried my best to keep this habit however during few weeks (2-3), the other courses workload took over and I had to break this habit. However, I made sure to catch up such that I don’t fall behind.  I worried about having less programming background compared to others too but I can now confidently say that through this course my programming skills have evolved. In fact, I as a person has also undergone evolution in sense that my studying habits, problem solving skills and analytical skills have improved. Having far more assignments, quizzes, tests and labs that I have had in any of my previous semester’s really forced me to change my studying habits such that I started working on things very early and even attended office hours to understand concepts that I had trouble with.

CSC148 sure is something. In my previous post I had written that I look forward to learning more new things as we progress in this course and I sure was right about this one. Throughout the semester we learned various new concepts, including object-oriented programming, recursion, trees, and linked list. I have wrote individual blogs about each of these so be sure to check them out if you haven’t already. I kept repeating that the word “practice” in that slog entry, trust me when I say this I could literally bet anything that practice had helped me tons in this course. This is how I prepared for my term test, I redid as many examples as I could to be confident about the material. So take my word, “Practise leads to improvement,” quoted by moifrom real-life experiences. 

If there is something I would like to go back and change, then it would be to tell myself that relax, everything works out in the end. As I had wrote in my previous post about my impression so far in the course, I stressed way too much about many things including those turtle exercise. I even stressed a lot about the first and second tests and that stress got to me because I made really stupid mistakes in those tests.

I have read some of my other classmate’s slogs throughout the year including few that I have already mentioned in my previous post but here are some others. A slogger by the internet domain Chenster also chose to revisit the slog about impressions of the first three weeks and I was surprised that we both share common experience. He like me also mentioned in his post that he was impressed by list compressions and also the pace of the course. We both recall and conclude to be satisfied with our overall experience in this course. Finally another excellent blogger is Humair, I was thoroughly improved by his slogs not only because he thoroughly explains the concept well but also because his writing flows very well. His post on BST insert is what I especially found interesting as he concisely explained the concept of Binary Search Tree and and even thoroughly explained the steps of creating the insert function for the binary search trees. From time to time in my other post I have mentioned those sloggers whose specific post was very well written thus refer to that if necessary. 

I really hope that you guys had as much fun reading my slogs as much as I had fun writing them. Although this is my second last post I want to remain in denial that it is not almost time to say goodbye to my wonderful readers. When you do read my next post, be sure to grab your tissues because you will certainly experience those feels  I'm only kidding guys. Even though my next post will be my last, it does not mean that I won't post in future, although it won't be as much as I did this semester, I will try my very best. 

Adios Amigos.

Thursday, 19 March 2015

Impressions of Week 9: Test 2 and Binary Search Tree

This week we had our second term test for CSC148 and ......






Yep this was my reaction soon after I left the exam. Why is it that you only remember the stupid mistakes you made after you have left the room. Why can’t the brain function when we need it to? Well it is too late to stress about that now but for some reason the memories of my stupid mistakes have become fond of me and aren’t willing to leave just yet. I guess I need to take this as a lesson such that I don’t make the same mistakes again. But then again, this is a common occurrence as I also heard several other people mentioning that they realized their mistakes after too. Misery loves company and to know that you are not alone is somewhat comforting.

This week even after our test, we had a class for the evening section where we learned about the binary search trees. Here is an example of a binary search tree.



From this tree you can see that it is a special kind of binary tree where the left sub tree consists of values less than the root( x < 7) and the right sub tree consists of values greater than the root(x > 7). This characteristic of binary trees leads to increased efficiency for instance when searching a tree for a specific value. Let’s say that we want to look for the integer 15. We first see the value contained in the root, and observe that its 7. We know that 15 is greater than 7 therefore, instead of also traversing the left sub tree, we will move onto the right sub tree, because we know that values greater than the root node can be found in the right sub tree.

Now that we have come so far in the course, I see that this courses teaches us how to create more and more efficient code, which I believe will be of great help in everyone’s future endeavors. List compressions to binary search tree and I’m sure in the remaining few weeks we will definitely learn even more interesting concepts which I can’t wait to share with you guys. 

I will sign off for now but as usual will return soon. Take care everyone.

Friday, 13 March 2015

Impressions of Week 8: Linked List



In week 8, we learned about another data structure called Linked List which was defined as linear set of nodes. The front of the sequence is known as the head, whereas the back of the sequence is known as the tail. In this class we will be viewing linked list as a sequence of nodes, each with a value and a reference to the next node. We have been highly encouraged to draw diagrams like below when working through practice examples and such. 



In class, we defined two classes LLNode to represent a single node and LinkedList to represent the linked list as whole. These were created in class using the following code.



 In order to perform certain actions such as adding a value in the list thus increasing the size or deleting the value thus decreasing the size, would require a programmer to be able to walk the list. Walking a list is usually of the following general form
           
            cur_node = self.front
            while <some condition here>
                        #do something here…
                        cur_node = cur_node.nxt
                        #after you do something you this allows you to move on the next

Let’s walk through the following __contains__ function which was discussed in class this week. 


This function returns a Boolean statement as to whether or not the linked list contains the desired value. Our while condition is to walk through the entire linked list, and we further check that if the value of the cur_node matched the value we passed on, then we return True and exist the loop. Else, we would move on the next list, and perform similar action until we find out desired value and return true. If it be the case that we cannot find the value after walking along the entire linked list, then we simply return False and exist the while loop. 

I have also read many of my other classmates slog from which Justin's blog post on Linked List is definitely worth a read.

Until next time everyone. 

Friday, 6 March 2015

TREES TREES TREES


Hello everyone,

I’m back with yet another blog post. Hope my other posts have been interesting and you guys had fun reading them. This week we have our second assignment due for CSC148 and on top of that I have a term test for my other class on the same day as the CSC148 assignment. Fortunately, I have been studying earlier of the test that now I can focus on the assignment with my group, which we also started earlier. Unfortunately, we have not been able to crack the minimax strategy. Minimax is a strategy which allows the player who uses the strategy to choose the best possible move such that he wins. Sounds simple, right? Well it is not as simple as it sounds, we have been working on it for such a long time; however, no avail yet.

Minimax why won’t you work??? Too much confusion. Well I can only hope that we can somehow get minimax to work before the deadline and submit a proper running code. *Fingers crossed*

Last week we were introduced to the Trees which are another abstract data type (ADT). This tree object can be compared to our real-life trees, because similarly they also have root, from which children’s may branch form. In class we defined trees as a set of nodes with directed edges between pair of nodes. The edge connects parent node to a child node. Furthermore, a node can contain value and the nodes with do not have any children are known as leafs. It is also important to note that a node can only have one parent and obviously the exception is root, which does not have any parent.



This is an example of a binary tree, which is a special kind of tree in sense that the number of children in a binary tree are restricted to a maximum of 2. Therefore each node has a branching factor also known as arity (max number of children) is 2. The children are known as left and right child, very convenient. In this tree, can you guess what root may be? That’s correct, it is indeed 2. What about the leafs? Right again, the leafs are 2, 5, 11 and 4.

Trees have several uses and few such uses include representation of hierarchical relationships, a directory structure or even relationships in arithmetic expression. Tree traversal is used to achieve various things because during traversal each node is visited and at the node the programmer can perform a specified action. Furthermore, the order of traversal can also be decided from the following 3 standard methods:

-        inorder – visit the node in between visiting its two children; thus, visit the left sub tree inorder, the node itself and then finally visit the right sub tree inorder.
In our tree example, for in order traversal we will visit in the following order 2,7, 5,6, 11, 2, 4, 9 and 5.
-         preorder – visit the node before its children; therefore, visit the node itself, then left subtree in preorder and finally right sub tree in preorder.
-         postorder – visit the node after its children; therefore, the left sub tree in postorder, right sub tree in postorder and then finally the node itself.

Try working on the preorder and postorder traversal of the tree in the image above. If you need more information on trees, post in the comment section below and I will be more than happy to discuss further. I also stumbled upon Thomson blog, which I feel is also very descriptive in explaining the concept of trees.