Sunday, March 9, 2014

Week 8

This week and last dealt with linked lists. Linked lists are similar to regular python lists, but with a few key differences. It is easier to view it pictorially:
 File:Singly-linked-list.svg                                                             Linked lists are named as such because each item is linked to the next. Each item has a head, such as 12 or 99, and a rest, which represent all the item after the value. At the end of the list is an empty node. By doing this, each rest will in itself refer to a small linked list; the rest of the value '12' would be a linked list of 99 and 37. As you may infer, since each rest is in itself a similar type of structure, we can view it recursively. But beyond that, I don't see what advantages we gain by using linked lists over regular lists; they seem harder to navigate and code, and have caused me nothing but trouble. I then looked over the internet for a use of linked lists, and found a few answers that gives an advantage to linked lists:      
  •  you want insertions/deletions with constant run-time
  • splitting and joining linked lists is efficient
  • linked lists share a tree-like structure, that may be useful in some situations
  • linked lists are flexible to modification
That being said -  and while I can see why these answers may hold true - I think ill be sticking with my simple python lists for now! That's it for this week.

No comments:

Post a Comment