Wednesday, October 23, 2013

Linked List (Python)

What is a linked list?

A linked list is a list that contains nodes that make the list itself. As you can see linked list has a recursive definition, therefore is possible to implement a linked list with recursive coding. A node within the linked list contain the value or element and a reference to the next node. The linked list contains only the head or the first node of the nodes that forms the list.

Removing a node

Removing a node in the linked list has to be done carefully. A linked list is like a chain of nodes, so removing a node you have to keep track of the rest of the chain from the node you trying to remove. 

Application

Linked list is useful to store a collection of objects, because nature that it can store any type of object in the list. Comparing to others date structure list, linked list is more efficient in various ways. Linked list doesn't have to create and copy its list again when expanding the list. The time is inserted and delete in the middle of the list is constant.  On the other hand, the disadvantages of linked list are the indexing of elements and the space its occupied comparing to an array list.  

No comments:

Post a Comment