Saturday, 6 February 2016

Week 4 -- class LinkedList

In this most recent week of CSC148, we worked on creating API's for and implementing different classes that had similar functions such as other Python types like lists. Some of the classes covered include Stack, Sack and LinkedList.

We continued our discussion from the week before on class Stack, which would simulate a real world stack where objects were placed one on top of the other, methods to remove items from the stack, and an important feature of them in that they had no particular order, rather just the item at the top being placed followed by the next. This class was later referred to in the week's lab, where students were to implement a function that utilized the Stack class, as well as implementing a new class Queue which followed a similar design recipe as the aforementioned class.

Another concept that we spent the majority of the week discussing was linked lists. These were similar to Python lists, except that every item that would be present in a regular list appeared in this new class as nodes, each holding a value. This is very helpful in that it saves a lot of memory when many items are inside the linked list - something that was touched upon a few times during lectures is the idea of imagining that you're working with 3 billion objects, and how in these situations efficiency could be critical towards saving memory and allowing the computer to run smoothly. We discussed and later implemented methods of class LinkedListNode and LinkedList, the latter of which was a collection of nodes created from the first class; the methods themselves were very similar to those of Python list types. We were told that drawing images was easier to visualize linked lists and that it would become a good practice to do so, as we had the advantage over computer in that our brains could lay out information in front of us and look at multiple items at the same time - a simplistic explanation but hopefully it gets the point across.

Next week is the midterm, of course some stress comes with writing any test, but I feel that by going over labs, implementing some classes on my own and reading over lecture slides should get me confident and prepared for Wednesday. Stay tuned next week where I'll discuss how it went.

No comments:

Post a Comment