Definition

Types of Lists

  1. Array-based (static) list — contiguous memory, O(1) random access, O(n) insertion/deletion (shifting required)
  2. Singly Linked List — each node points to the next; O(1) insertion/deletion at head, O(n) access
  3. Doubly Linked List — nodes have both next and previous pointers; allows backward traversal, easier deletion
  4. Circular Linked List — last node points back to first, useful for round-robin scheduling, buffering

Array vs Linked List (classic comparison table)

Feature Array Linked List
Memory Contiguous Scattered (dynamic)
Access time O(1) O(n)
Insertion/Deletion O(n) (shift needed) O(1) (if position known)
Memory overhead None extra Pointer storage per node
Size Fixed (static array) Dynamic

Core List Operations

Exam Angle

A very common question: "When would you prefer a linked list over an array?" — answer: frequent insertions/deletions, unknown/variable size at compile time. Reverse: prefer array for frequent random access.

📌 Sample & Repeated FPSC Questions (2016–2026)

2026, Paper I, Q3(b) (6 marks) — What are arrays? Describe one advantage and one limitation.

An array is a linear data structure storing a fixed-size, ordered collection of same-type elements in contiguous memory, accessed directly by index.

Key reasoning points: