Wednesday, 1 April 2015

Lamenting about Linked Lists

In week 8 of the course the focus was changed from trees to a new data structure in Python called a linked list. A linked list is similar to a normal python list in that it stores values in order and every value has a position that relates to the other values in the list. What differentiates between the two is how the values in the list can be manipulated.

While working with linked lists the focus is on manipulating from the front and back of the list. Because of how the list is connected it makes manipulations from the front/back much more efficient than if you were working with a regular list. However, if you were scanning for a certain object in the middle of the list it would be more advantageous to use a regular list.
An example of adding a node to a linked list, it makes two new connections if it is in the middle

No comments:

Post a Comment