1. Gyanastra
  2. Data Structures
  3. Singly Linked Lists
  4. Advantages of Linked Lists over Arrays and the Head Pointer
Free lesson, no account needed 5 min read 8 practice questions after it
Asked in past papers3 times
  • GATE CSE20251997
  • UGC NET2004

Data Structures · Singly Linked Lists

Advantages of Linked Lists over Arrays and the Head Pointer

Overview

A singly linked list is a dynamic data structure built from structures (in C), where each node is linked to the next via a pointer.
It is one of the two popular data structures used to store information (input or output), the other being arrays.
Unlike arrays, a linked list can grow and shrink while the program runs, and a head pointer keeps track of where the list starts.

Key concepts

  • Singly linked list: a dynamic data structure built from structures (in C), where each node is linked to the next via a pointer.
  • Two popular data structures used to store information (input or output): arrays and structures (linked structures).
  • Head pointer: a pointer that points to the start of the linked list. It is declared as a pointer to the node structure, e.g. struct node *head;. It is a pointer to a structure of type node, i.e., it points to the first node of the list.
  • Dynamic vs static: using structures, the data structure can be created dynamically; using arrays, the need/size has to be static.
Data structure diagram: Advantages of Linked Lists over Arrays and the Head Pointer
Figure. Advantages of Linked Lists over Arrays and the Head Pointer

How it works

  1. When storing information, you can choose between arrays and structures (linked structures).
  2. In C, a plain array's size is fixed once it is allocated (even if allocated at run time with malloc), so it cannot grow or shrink as elements are added or removed; a linked structure can.
    So if you do not know your requirement well ahead of time, you must leave it to structures.
  3. Using structures, the data structure can be created dynamically; using arrays, the need/size has to be static.
  4. On the go, if you feel you need one more element, you can create the element and add it into the link. On the go, if you find you do not need some of the nodes/links, you can free them up.
  5. The structure is used to create the node, and in general a pointer head is created initially:
    struct node *head;
    
  6. Every link has a pointer that points to where the linked list is starting from. Without this pointer you cannot keep track of everything.
  7. head is a pointer to a structure of type node — i.e., it points to the first node of the list.

Formulas

  • struct node *head; — declares head as a pointer to a structure of type node, pointing to the first node of the list.

Comparison

FeatureArraysLinked list (structures)
Dynamic creation in CNot possible (no dynamic array creation)Possible — nodes created dynamically
Size requirementMust be known/static ahead of timeCan grow/shrink on the go
Adding an element laterNot possible dynamicallyCreate a new element and add it into the link
Removing an element—Free up the unneeded nodes
Tracking the startBase address of arrayhead pointer to the first node

Revision summary

  • Arrays cannot be created dynamically in C; linked structures can.
  • If the requirement is not known in advance, use structures (linked list), not arrays.
  • Nodes can be added on demand and freed when no longer needed.
  • The head pointer is essential: it points to the first node and lets you keep track of the whole list.
  • head is declared as struct node *head; — a pointer to a structure of type node.

Previous-year exam insights

  • Insertion/deletion at the front of a singly linked list is O(1)O(1); insertion/deletion at the end is O(n)O(n) unless a tail pointer is maintained, in which case appending is O(1)O(1) but deleting the last node still needs O(n)O(n) (to find the predecessor).
    Asked inGATE 2025GATE 1997
  • Concatenating two lists in O(1)O(1) requires access to the last node of the first list: a singly linked list with only a head pointer needs O(n)O(n), whereas a list with a tail pointer (or a circular list with a tail pointer) does it in O(1)O(1).
    Asked inGATE 1997GATE 2025
  • A singly linked list allows moving only forward (to the successor); accessing the predecessor (backward step) is O(n)O(n), which is why operations like 'backup' or deleting a node given only a pointer to it are O(1)O(1) in a doubly linked list but not in a singly linked list.
    Asked inUGC NET 2004
  • Random access by index is O(1)O(1) for arrays but O(n)O(n) for linked lists; searching an unsorted list is O(n)O(n) in both, and a sorted array supports O(log⁡n)O(\log n) binary search while a linked list does not.
  • A linked list uses extra memory per element for the pointer(s) (one per node in singly, two in doubly linked lists) and nodes are not contiguous, so it has poorer cache locality than an array.
  • Meld/merge of two unsorted linked lists can be done in O(1)O(1) by linking the tail of one to the head of the other, whereas merging two heaps or balanced BSTs costs more (building a heap from n elements is O(n)O(n), merging two BSTs is O(n)O(n)).
    Asked inGATE 2025
Pages 1–2 of 2