data-structures Linked List Introduction to Linked Lists


Example

A linked list is a linear collection of data elements, called nodes, which are linked to other node(s) by means of a "pointer." Below is a singly linked list with a head reference.

         ┌─────────┬─────────┐   ┌─────────┬─────────┐         
 HEAD ──▶│  data   │"pointer"│──▶│  data   │"pointer"│──▶ null 
         └─────────┴─────────┘   └─────────┴─────────┘         

There are many types of linked lists, including singly and doubly linked lists and circular linked lists.

Advantages

  • Linked lists are a dynamic data structure, which can grow and shrink, allocating and deallocating memory while the program is running.

  • Node insertion and deletion operations are easily implemented in a linked list.

  • Linear data structures such as stacks and queues are easily implemented with a linked list.

  • Linked lists can reduce access time and may expand in real time without memory overhead.