Sunday, 15 March 2015

week #9: impressions of week 8.

This week, we learned about the linked list. It can be seen as a sequence of nodes, each has a value and a reference to next node. When I first saw it, it think it is just like the tree writhing in a horizontal way. However, there is much difference compared with a tree. For instance, linked list is a wrapper class of LLNode which represent a single node, but there is no wrapper class for a BTNode. Also, an empty linked list is an instance of the class, with attribute values set to show it’s empty, while an empty tree is represented as None.
Although, we've looked over the codes in linked list class and learned how it works, I'm still confused about it because it is not in way i used to think. The first thing we learned about is to traverse a linked list, which has a pattern that is pretty helpful:
And the most important part in the linked list is how to mutate a linked structure. It is easy to understand how it changes through the code if we draw a simple diagram, which shows both the front and the back and the current node and previous node. Like this:
Basically, those are what we learnt about linked list. If we look at the code of a linked list, it is very simple and sometimes it is simple enough that I am not sure how it can work through python. Every time I try to write a code like this , I always think in a difficult way and as a result, the code I write keeps failing. In order to get over it, I find that do lab exercise including the extra practice in the back every week is a good way to learn how to use it properly.

No comments:

Post a Comment