Saturday, 11 April 2015

llnode linkedlist

In week 7 professor Danny showed us class LLNode and class LinkedList. At first I don't quite understand the point of these two classes because I think class List will be enough for us to implement all the functions needed. After a whole week, these two new classes begin to make sense to me.

Just like binary tree node(BTNode), LLNode is a class that represents each node in a linked list. Class LinkedList is a collection of LLNodes. A LLNode contains two attribute: its value and the next Node it refers to. You may store value in LLNode and it can be a list, tuple, dict... Linkedlist contains 3 attributes which are front, back and size of the Linkedlist.

In lectures and labs we are asked to implement some methods for class LinkedList: make modification to LLNode at a certain index, add or delete LLNode to a LinkedList ,and search for a LLNode in the whole LinkedList. Some of the functions require the implementation of recursion and some not. With these methods LinkedList can behave in a similar way as normal List(array).

Though these two class seem similar to each other, LinkedList do have some advantages over the normal list because it makes the modification of certain items within the list more efficient. Not like the normal list, linked list is like a whole collection of separate objects that is connected in a sequence, which means the computer don't have to get the slice (go through the whole normal list) to make modifications to items. In this way we can achieve higher efficiency by using LinkedList in some situations.

Though by using linked list we reduce the computations need to be done by the computer, I think it may still have some limits comparing to the normal list.
However I'm still ignorant of these limits because I never used linked list in
the assignments(how pathetic!). I'm looking for some further study to gain some deeper insight in this new data structure.

No comments:

Post a Comment