Tuesday, 17 March 2015

CSC148 - Entry 7

Entry no. 7, Week 9:

Topics

1. Impression on Week 8

 

This weeks topic is Week 8; Linked Lists.

An easy way to describe a linked list is as a tree with an arity (branching factor) of 1 which means there is only 1 'child' for each node.
This also means that this linked list will be linear and traversing can be accomplished by iteration where one can loop through the list until the end or until an object is found.
Example of a linked list

Generally for a linked list a class is used to keep track of it's information, a Wrapper class. Typically, it stores the size, front and end of the linked list but can keep track of anything within the linked list. 

Example of a wrapper class 

With further implementation of __str__, __repr__, __eq__ and other methods, a linked list can be extremely useful.

Something to be weary of when using iteration on a linked list is mutation. If one isn't careful, objects inside the linked list may be changed or swapped with each other.

No comments:

Post a Comment