thecodex.expert · The Codex Family of Knowledge
Section Hub

Data Structures

How data is organised in memory — and why the choice of structure determines the speed of every operation that touches it.

12+ structures Requires: CS Concepts Big O tables included Last verified:

A data structure is a way of organising data in memory so that specific operations can be performed efficiently. Arrays give O(1) random access. Hash tables give O(1) lookup by key. Linked lists give O(1) insertion at the head. The wrong structure for a workload makes programs slow; the right one makes them fast.

Every page in this section includes: a canonical definition, formal Big O complexity table, memory layout diagram, and implementations in at least C, Python, and Java. Sources from Cormen et al. CLRS and Knuth TAOCP.

Linear Structures

Data arranged in a sequence — each element has a position.

Key-Value Structures

Trees & Graphs

Trees

Hierarchical structure. Binary trees, N-ary trees, heaps. Used in file systems, compilers, and priority queues.

Coming · Session 10
Heaps

Specialised tree satisfying the heap property. O(log n) insert/extract-max. Foundation of heapsort and priority queues.

Coming · Session 10
Graphs

Vertices and edges. Directed, undirected, weighted. The structure behind social networks, maps, and dependency graphs.

Coming · Session 11

Quick complexity reference

StructureAccessSearchInsertDeleteSpace
ArrayO(1)O(n)O(n)O(n)O(n)
Linked ListO(n)O(n)O(1)*O(1)*O(n)
StackO(n)O(n)O(1)O(1)O(n)
QueueO(n)O(n)O(1)O(1)O(n)
Hash TableN/AO(1) avgO(1) avgO(1) avgO(n)
BST (balanced)O(log n)O(log n)O(log n)O(log n)O(n)

* Insert/delete at known node (head/tail). O(n) if finding the node first. All complexities are worst-case unless noted.