Sunday, March 8, 2015

Linked Lists

    This week we learned about a new data structure called 'linked list'. A linked list is a group of nodes that represents a sequence. Each node in a linked list consists of a data and a reference (link) to the next node in the sequence.


   At first I didn't really understand what a linked list was, but after we worked on a few example methods such as the __getitem__ and append method for our LinkedList class, I started to get a better understanding of what it was and how it works. Since our LinkedList class only had a 'front' and a 'back' it was very clear that in order to access an item (that wasn't the first item or the last item) in a linked list we would have to iterate through the list i.e. walk along the list with a for loop. Another thing that also became clear to me and actually surprised me a bit was that reverse traversing ('walking backwards') can be extremely difficult!

    Due to the TA strike I had a slight bit of difficulty doing lab 07 with linked lists because even though I understood some of the things, there were also a few things that I didn't quite fully understand until I spent some time drawing out a linked list and seeing how to properly implement methods for the linked list.

No comments:

Post a Comment