Overview
This document provides a consolidated architectural summary of essential data structures. It details performance complexities, memory management behaviors, and algorithmic trade-offs across arrays, linked lists, skip lists, heaps, search trees, hash tables, tries, disjoint sets, and graphs.
1. Linear Data Structures
Array List
An Array List is an ADT wrapper built over a dynamic array that automatically resizes when capacity limits are hit.
- Random Access: Constant-time indexing via contiguous memory calculation.
- Contiguity: Elements reside in contiguous memory slots with zero gaps.
- Resizing Logic: Doubling strategy allocates a new array of capacity , copies elements, and frees old memory.
Complexity Analysis
| Operation | Unsorted Array List | Sorted Array List |
|---|---|---|
| Find | Avg , Worst | Avg (Binary Search), Worst |
| Insert | Avg , Best at end | Avg (Requires shifting) |
| Remove | Avg , Best at end | Avg (Requires shifting) |
| Space |
Computer Science Introduction/Data Structures/Introductory Data Structures/Linked List
Sequential chains of individual node objects connected via explicit pointers.
- Singly-Linked: Node tracks
dataand a singlenextpointer. - Doubly-Linked: Node tracks
data,next, andpreviouspointers. - Modification Logic: Pointer redirection takes time once the target node is located.
Complexity Analysis
| Operation | Singly-Linked List | Doubly-Linked List |
|---|---|---|
| Find | Avg , Worst | Avg |
| Insert (Head/Tail) | ||
| Insert (Middle) | search + swap | search + swap |
| Space Overhead | (1 pointer/node) | (2 pointers/node) |
Skip List
A probabilistic data structure augmenting a linked list with multi-level forward pointers, enabling logarithmic lookups.
- Probabilistic Height: Node levels are assigned via coin flips (probability ).
- Multi-Level Traversal: Search starts at top level of head node, skipping large spans before dropping down levels.
Complexity Analysis
| Operation | Average Case | Worst Case |
|---|---|---|
| Find / Insert / Remove | (If coin flips degrade to height 1) | |
| Space Overhead | Expected | Worst |
2. Priority & Search Trees
Heap
A complete binary tree enforcing relative priority ordering between parents and children.
- Array Mapping: Flat array storage where child offsets resolve to and .
- Heap Invariant: Min-Heap () or Max-Heap ().
Complexity Analysis
| Operation | Complexity | Operational Detail |
|---|---|---|
| Peek | Root element lookup at index 0. | |
| Insert (Push) | Appends to tail + Bubble-Up rebalancing. | |
| Pop (Extract) | Swaps root with tail + Trickle-Down rebalancing. | |
| Space | Flat contiguous storage with no empty slots. |
Binary Search Tree (BST) Variations
| Structure | Find (Worst) | Insert (Worst) | Remove (Worst) | Balancing Mechanism |
|---|---|---|---|---|
| Standard BST | None (Degenerates on sorted input). | |||
| RST (Treap) | Probabilistic random priorities ( avg). | |||
| AVL Tree | Strict balance factors () via rotations. | |||
| Red-Black Tree | Relaxed color rules; optimized for writes. |
B-Tree & B+ Tree
“Fat” balanced search trees designed for disk storage and database indexing by maximizing branching factor .
- B-Tree: Internal nodes store search keys alongside actual data records.
- B+ Tree: Internal nodes store search keys only; all data records reside exclusively in linked leaf nodes for efficient range sweeps.
| Metric | B-Tree | B+ Tree |
|---|---|---|
| Find (Worst) | ||
| Data Placement | Any node level | Leaf nodes exclusively |
| Range Queries | Requires tree traversal | Fast sequential leaf list walk |
3. Hash-Based & String Data Structures
Hash Table & Hash Map
Associative structures mapping keys to array slots via string hash functions .
- Open Addressing: Linear Probing, Double Hashing, Cuckoo Hashing.
- Closed Addressing: Separate Chaining (Linked lists or BSTs per bucket).
| Strategy | Find (Avg) | Find (Worst) | Key Characteristics |
|---|---|---|---|
| Linear Probing | High cache locality; sensitive to clustering (). | ||
| Separate Chaining | Handles high load factors () gracefully. | ||
| Cuckoo Hashing | worst | Guaranteed lookups via two hash candidate slots. |
String Searching Structures
| Structure | Find (Avg) | Space Complexity | Primary Advantage |
|---|---|---|---|
| Multiway Trie | Fastest prefix queries; memory inefficient for large alphabets. | ||
| Ternary Search Tree (TST) | Space-efficient hybrid using 3 child pointers per node. | ||
| Disjoint Set (Union-Find) | Amortized near-constant time dynamic set partitioning. |
4. Graph Representations
| Representation | Edge Lookup | Find Neighbors | Space Complexity | Best Use Case |
|---|---|---|---|---|
| Adjacency Matrix | Dense graphs () | |||
| Adjacency List | worst | Sparse graphs (BFS, DFS, Dijkstra). |
5. Master Summary Table
| Data Structure | Search (Avg) | Search (Worst) | Space Complexity | Primary Optimal Use Case |
|---|---|---|---|---|
| Array List | / | / | Fast random indexing (Sorted via Binary Search). | |
| Linked List | Frequent head/tail insertions. | |||
| Skip List | Concurrent logarithmic ordered lookups. | |||
| Heap | root | arbitrary | Priority queue dispatching ( peek). | |
| AVL Tree | Read-heavy lookups requiring guaranteed bounds. | |||
| Red-Black Tree | Write-heavy general purpose maps (std::map). | |||
| B+ Tree | Database indexing and file system storage. | |||
| Hash Table | Exact match key-value lookups. | |||
| Multiway Trie | High-speed auto-complete with small alphabets. | |||
| Ternary Search Tree | Memory-efficient dictionary auto-complete. | |||
| Disjoint Set | Kruskal’s MST and connected components. | |||
| Adjacency List | Graph traversal algorithms on sparse networks. |