There are many methods or functions that can work with linked lists. It is possible to check whether the list contains a certain value, to retrieve a value with its index, add a node anywhere in the list, delete nodes anywhere in the list etc. The majority of these things require moving along the list and examining each item. This can be done by creating a current_node variable and setting it to the front node of the list, then moving current_node along the nodes in the list.
current_node = self.front
while <condition>:
<action>
current_node = current_node.nxt
*self refers to the class that keeps track of the entire list
I found the concept really easy to grasp, and it is relatively easy to work with linked lists as long as I draw out examples as I am writing methods/functions that work on linked lists. I didn't find linked lists to be unpleasant, but I didn't find it very interesting either, but I'm sure there will be more fun new things coming up for us to cover in the course.

Great explanation on LinkedList. For me, LinkedList concept was a bit hard... I just hope I did well on my term 2 test.
ReplyDeleteGood comprehension, and I like your blogs' pages!
ReplyDelete