Saturday 7 March 2015

6 - A Wild Linked List Has Appeared

The TA strike has commenced this week, so classes have been crazy this week. Nevertheless it's good to know Danny is an unrelenting force and term tests and assignments will go on as scheduled!

This week, we learned about a new data structure, linked lists. They are nodes that not only have a value, but also have a reference to another node that may also have a value and may also have a reference to another node and so on. This at first sounds confusing when written in words, but Danny told us to draw a picture when thinking about lists which really helped my understanding of this type of list.
As seen in the above image, the first two nodes in the linked list have both a value and a reference to another node. The third node, similarly, has a value but refers to None, indicating that this is the end of the list. Linked lists are recursive, and takes advantage of embedded references

To me, linked lists still seem a little confusing but I'm happy I know how to write them and such. I am hoping by the end of this week when I study them enough I'll understand why they are used in programs.

No comments:

Post a Comment