A linked list is a data structure where the list elements are not necessarily stored sequentially but rather each element contains a reference to the next (and optionally the previous) element in the list. This tag should be used with additional tags indicating the programming language being used ([c], [c++], [java], etc.) and any libraries or plug-ins being used such as [c++-standard-library]. The post itself should contain source code for the issue.
A linked list is a data structure in which the elements contain references to the next (and optionally the previous) element. Linked lists offer O(1) insert after and removal of any element with known memory location, O(1) list concatenation, and O(1) access at the front (and optionally back) positions as well as O(1) next element access. Random access and random index insertion/removal have O(n) complexity and are usually unimplemented.
Types
Lists are the canonical recursive (or inductive) data type.
Specific Implementations
Almost every programming language provides support for list data structures. They are particularly common in functional languages, because their inductive properties lend themselves to elegant iterative and recursive abstractions.
How they work
Linked lists are made up of nodes, each node takes up a space in memory. The order of nodes in memory is irrelevant, this is because linked lists use pointers. Pointers, as the name suggests, points to the memory address of a node. There is a start pointer which points to the first node, a null pointer for the last node which shows the end of the list. Each node also has one or two pointers depending on whether its a singly or doubly linked list.
Performance
The flexibility of linked lists is somewhat offset by the complexity of some operations on lists (accessing an element at index n in the list is O(n), while for arrays it is O(1)). In practice, they are a very disadvantageous structure for random-access-based algorithms. The performance of lists and arrays is of the same order (O) for operations that deal with every element of the list in order.
However, they have good performance when dealing with large lists in which random access based on indices is not required but the removal of elements at known positions in memory is.
See also