Wednesday, March 4, 2015

Week 8: Linked List



Linked Lists (LL) are fun tool to use in programming because their algorithms are interesting to traverse. It is helpful to view a LL as a rope with knots at the beginning, throughout the rope, and at the ending. Imagine picking up the rope from the beginning (we will call this the front of the Linked List) and follow the rope to the next node. The first node refers to the second node, the second node refers to the third node and this process repeats until you reach the last node (back) which refers to nothing. This is considered a singlely LL as opposed to a doubly linked list where each node refers to the node before and after it if they exist. One advantage to using a LL is that it can be added to dynamically. Some common methods used in LL are inserting or deleting a node, finding the number of nodes, and searching for a node. The time complexity for these methods in the worst case scenario of a singly LL is O(n) where n is the number of nodes. The slow look up time is because in order to get to the last item in the LL, you have to start at the front and follow the references until you reach the last item in the Linked List.

No comments:

Post a Comment