Saturday, 28 March 2015

Week 11


Hi everybody!  In this week’s post, I would be revisiting an earlier posting of mine named, ‘Object Oriented Programming Summary’, and would be comparing my experience in learning about OOP with those of my classmates.

Over the duration of the course, I have come to strengthen my understanding of Object Oriented Programming. In the initial stages, I had some difficulty understanding classes and the notorious ‘self’. In my earlier post, I demonstrated a diagram, which was like a box with smaller boxes inside that helped me visualize the process of OOP. At that point in time, I still had some problems trying to wrap my head around the notion of inheritance and especially about functions can inherit class-defined methods and variables. Working on Assignment 3 has helped me understand how this works. Furthermore, working on the assignments and labs has also helped me understand the concept of ‘self’ better. Today, I understand that self helps to state that the method works on the instance or object defined in that class. In other words, it helps point to the class where the method should work.

I have decided to compare my experiences on OOP with those described in the following blogs:

http://akcolter.blogspot.ca/

The blogger of this blog seems to have a different experience from mine, in which he/she found the concept of OOP to be intuitive. However, the blogger had also found the concept of inheritance to be difficult to grasp. One approach that the blogger has used to clarify his/her doubts is the use of the Python Visualizer, which I think is a great idea and I will use this resource more in the future.

Another blog that compared my experiences to is http://klaracsc148.blogspot.ca/. The blogger had a completely different experience from mine, in which she found the concept of classes to be hard to grasp whilst the concept of inheritance to be easier to grasp. I particularly found her description of ‘composition’ to be insightful because, although I was aware of that concept, I was not aware of the technical term for that. Her description of classes has also helped me understand classes better.

Lastly, I also decided to compare my experiences with that of those described in this blog, http://ak148slogaddress.blogspot.ca/. Although, the blogger has not really described his/her experiences, they have done a great job in explaining the concepts of property and inheritance. I particularly found their advice of ‘DRY or Don’t Repeat Yourself’, to be helpful in programming.

Therefore, I have come to realize that everyone in the course has found different aspects of OOP to be easy or difficult. Their blogs have truly helped me improve my understanding of not only OOP but also other concepts. Furthermore, their doubts have also helped me question my understanding and develop my knowledge.

That is all for this week, I hope everyone is having a great week. Please check out the linked blogs and leave a comment! Thank you!

Friday, 20 March 2015

Linked Lists


Hi everybody! In this week’s entry, Linked Lists will be discussed.

A linked list is linear sequence of nodes, with the first node being referred to as the front or head of the sequence, and the back or last node being referred to as the tail of sequence. A linked list may essentially be seen as a sequence of nodes, each containing value and a reference to the next node. In our lectures, we used the LLNode class to define a node and the LinkedList class as a wrapper class to represent the linked list as a whole.

Traversing a linked list is very different from traversing Trees. A common algorithm, as discussed in class is that of setting a reference to the front of the list and then using a while loop to come to the node desired. At every step of the while loop, the subsequent node is referenced to.

One of the harder concepts discussed in class, was the concept of mutating a linked list. I found it especially hard to mutate list when we had to ‘walk’ the linked list with two references. This traversal method was demonstrated using the example of the ‘prepend’ method. I have found it this concept to become much clearer when I tried out the lab exercises for this week. It is quite a hurdle to get our concepts cleared out with the TA strikes but I have found discussing with friends and office hours to be useful.
That is all for this week, I hope everyone is having a great week. Please check out the linked blogs and leave a comment! Thank you!




http://2015csc148slog.blogspot.ca/

Friday, 13 March 2015

Tree Traversal and Binary Search Trees or BST


Hello, everybody! The topic for this week is Tree Traversals and Binary Search Trees or BST.

Tree Traversal is the process of visiting the individual nodes of a tree, with the objective of carrying out an operation or implementing a function at each.  There are essentially three ways to traverse a tree. The first is known as the in-order traversal, on which, a node is visited in between visiting its two children. The second is called the pre-order traversal and in this traversal, a node is visited before its children. Finally, the last method is the post-order traversal, and in this, a node is visited after visiting its children. Essentially, the different traversal methods, each give the programmer different powers and capabilities in carrying out operations or functions while tree traversal and thus, are useful in different situations.

 A BST is a special case of the Tree ADT, in which each root can have only a maximum of two children. Furthermore, in a Binary Search Tree, data is organized in such a way that for every root, its left child contains a value smaller than the value the root contains. Likewise, the root’s right child contains a value larger than the value the root contains. Therefore, data is essentially well-organised in a Binary Search Tree. Thus, it may be concluded that Binary Search Trees are extremely useful in sorting algorithms. Lastly, it should also be noted that pre-order traversal only makes sense in BSTs. Here is an example of a BST:


The problem I faced in this week’s lectures was in the BST insert and delete worksheet. I found it pretty hard to implement those methods because, tree traversal is still a bit unintuitive to me. I hope to get a better understanding of it in the labs.

That is all for this week, I hope everyone is having a great week. Please check out the linked blogs and leave a comment!http://2015-csc148.blogspot.ca/

Friday, 6 March 2015

Trees ADT



Hi everybody! This week in class, we learnt about Abstract Trees Data Types or ADT. Trees Abstract Data Types are a method of organizing data in Computer Science. Using a Tree ADT class, the data is organized into multiple nodes, with the first node named the root. A root may have none to multiple children. Each of these children is also known as a node, and each of the children may have none to multiple children themselves. If a node had no children, it is known as a leaf. On the other hand, a node with one or more children is known as an internal node. The arity or branching factor of a node is the maximum number of children any node can have. Furthermore, an edge connects a parent node to a child. Essentially, each Tree ADT maybe divided into multiple smaller Tree ADTs or subtrees, with each child being considered the root of a subsequent smaller tree. The length of a Tree ADT is the number of edges on it and the path of a tree is a sequence of nodes, which are all interconnected by edges.  The height of a tree is the maximum path length plus one. Lastly, the depth of a node is the height of the whole tree minus the height of the sub tree rooted at that node.
The following diagram may help visualize the concept of Tree ADTs. 




It may be concluded that Trees may prove extremely helpful in representing hierarchy. Furthermore, it maybe deduced that recursion plays a major role in traversing Trees ADT.

Although I believe that I understand Trees ADT pretty well one of the topics I find pretty complicated is the concept of traversing trees. I have found the lab and in-class worksheets pretty useful in helping me deal with the issue, however, I believe I would require more practice in this topic.

Well, this is all for this week, please check out the linked blogs for more information on Trees ADT!