Data Structures · Singly Linked Lists
Self-Referential Structures and the Singly Linked List Node
Overview
A singly linked list is a chain of nodes, each node being a structure that contains a pointer to a structure of its own type.
This self-referential structure is the foundation of dynamic list building: nodes are created at run time and joined by their links into a one-directional chain.
Key concepts
- Singly linked list: a collection of nodes, where each node is a self-referential structure.
- Self-referential structure: a structure that contains, inside it, a pointer that points to a structure of the same type.
- Node structure: the structure with tag
node, holding a data part and one link pointer:
struct node
{
char data;
struct node *link;
};
struct node— the structure with tagnode.char data— the data part, stored as a character.struct node *link— a pointer that points to a structure of the same type (struct node).- The list is called single linked because every structure has only one link (one link, single link, single link, ...).
- Movement is possible in only one direction: forward from a node to its next node; you cannot come back to the previous node.
How it works
- Declare the self-referential node structure (data plus one pointer to the same structure type).
- Dynamically create many such structures (nodes).
- Link them one after another using the
linkpointer of each node, so that from one node you can reach the next node. - The resulting chain of nodes is the singly linked list.
Example arrangement: 6 structures are created and linked in a chain — from the first node you can reach the second, from the second the third, and so on. Reaching a node gives access to the next node through its link.
Revision summary
- The structure must be self-referential: it contains a pointer to its own structure type (
struct node *link). - Each node in a singly linked list has exactly one link — that is why it is called a single linked list.
- Traversal is one-directional only (forward); backward movement is not possible.
- Nodes are created dynamically and joined by their link pointers to form the list.
Previous-year exam insights
- In C, a structure cannot contain a member of its own type (that would be infinitely sized); it may contain only a pointer to its own type, which is why the self-reference must be through a pointer.
Asked inGATE 2017GATE 2026 - A NULL-terminated list is detected by testing the link pointer against NULL (e.g., node->next == NULL identifies the last node);
dereferencing a NULL pointer is undefined behaviour and must be guarded.
Asked inGATE 2017GATE 2026 - Recursive list operations (e.g., counting nodes) need a base case for the empty/NULL list and a recursive case that advances to next; the size of a non-empty list is 1 + size of the rest.
Asked inGATE 2026 - Appending one list to another requires traversing to the last node of the destination list, so it takes time; if the destination list is empty the head pointer itself must be updated.
Asked inGATE 2017 - A doubly linked list can be implemented with a single pointer per node by storing the XOR of the previous and next node addresses (XOR-linked list), but traversal then requires an extra pointer to the previous or next node.
Asked inUGC NET 2023 - Insertion at the front of a singly linked list is , while insertion/deletion at a given position or at the end requires traversal; searching is since only forward traversal is possible.
Singly Linked List Node Chain
Drawing the diagram…
Shows six dynamically created nodes joined by their single link pointers into a one-directional chain ending at NULL.