Linked Node Data Structure

Context: FIT1008_MOC Β· the non-contiguous alternative to an Array (Data Structure) Β· made of Nodes Β· realised as LinkList

Quick Revision

  • 🎯 Objective: store a collection as a chain of Nodes βž” no contiguity, no random access; reach a position by walking links.
  • πŸ“¦ Core Components: singly / doubly / circular / sentinel variants.
  • ⚑ Key Constraint: insert/delete at a held node vs to reach index β€” the exact mirror of an array.

πŸ“ Core

1. The Structure (Chain, No Random Access)

  • Composition βž” chain of Nodes, each item + a link to the next βž” not contiguous, no random access.
  • Fundamental trade βž” insert/delete at a held node (rewire links) vs to reach index βž” arrays are the mirror image.

2. The Linked-List Family

  • Singly βž” head, tail/predecessor.
  • Doubly βž” prev+next βž” delete-given-node + tail (with tail pointer) βž” deque/LRU.
  • Circular βž” tailβ†’head βž” round-robin.
  • Sentinel βž” dummy head/tail nodes βž” remove empty-list/head-insertion special cases (every real node has a predecessor).

βš–οΈ Core Decision Matrix

OperationArray (Data Structure)Linked nodes
access index
insert/delete at a known node (shift) (relink)
insert/delete at index walk + relink
memoryone block (+ spare); Dynamic Array Resizingper-node pointer; grows freely
cache localityexcellentpoor (pointer chasing)

When It Flips: prefer linked for frequent front/held-node insert-delete with little indexed access (stacks, queues, LRU caches, adjacency lists); prefer array for random access, binary search, cache-sensitive scans.

πŸ“Š Exam Execution Trace

Manual Execution Trace

Insert at index decomposed:

Step / StatePhaseCost
0 (Init)β€”β€”
1walk head β†’ node
2rewire new.link, prev.link
totalinsert-at-index

⚠️ Common Mistakes

  • πŸ’‘ ” insert” needs the node in hand βž” reaching index first is still , so insert-at-index is , not .

🧠 Active Recall