Saturday, 13 February 2016

Week 5 SLOG - Linked Lists

We actually didn't learn much this week since Monday was spent to discuss Wednesday's test and assignment 1. As stated, Wednesday was the test. This week's lab and Friday's class were the only instructional  classes which we covered Linked Lists. The type of Linked List I'll talk about in this SLOG are singly Linked Lists.

The Linked List is set of nodes. Each node contains its value and the reference to the next node in the Linked List. This allows the nodes to be linked as if it was a list.

The benefit of a Linked List is that it avoids Python's directive to allocate large blocks of adjacent memory for long lists. This means that a Linked List should be able to be extended indefinitely until the computer runs out of memory as its nodes can be widely dispersed throughout the system. It also is beneficial when the list is going to be modified as removing an object from a standard Python List will shift every object that appears after the removed object one index forward. This makes it better than a List in implementing a Queue.

The cons of a Linked List include using more memory for each object in the list as it must also have a reference to the next node in the Linked List.

The benefits were best illustrated in Friday's presentation of a Queue and Stack implemented with List and a Queue and Stack implemented with Linked List. The running time of the Linked List implemented ADTs grew linearly with size increase while the running time of a Queue implemented with List grew in a quadratic manner in relation to size. The List implemented Stack grew in a linear fashion.

The benefit is seen only with large lists so I wonder if we'll be learning about asymptotic running time after reading week. In other news: there wasn't enough time for the test!!!

No comments:

Post a Comment