Conceptual
Login

How Linked List Nodes Store Data and Pointers in Non-Contiguous Memory in C

A linked list is a dynamic list representation in which each element occupies its own independently allocated block — a node containing a data field and a pointer field holding the address of the next node — so the elements need not be contiguous in memory. It exists to escape the limitations of the array representation, where contiguity forces the size to be fixed in advance and growth requires allocating a new block and copying every element; a linked list instead grows and shrinks one node at a time at the cost of extra memory for the links and the loss of address arithmetic. Because the only handle retained is the address of the head node and a null pointer terminates the chain, elements are reachable only by following links from the head, making access, insertion, and deletion O(n) rather than the array's O(1) indexed access. This is a foundational topic in data structures, framing the general trade-off between contiguous and linked representations of a sequence.