Data Structures & Algorithms
The Logic Ledger
Interactive visualizations, code in three languages, complexity breakdowns. Built for engineers who want to see it, not just read about it.
Featured
O(n²)Bubble Sort
Repeatedly walks through the array, compares adjacent elements, and swaps them. Each pass bubbles the largest unsorted element to its final position.
Open visualizerTime Complexity
Sorting
6 algorithms
Bubble Sort
Repeatedly swaps adjacent elements. Simple but slow. Good for learning.
Selection Sort
SoonFinds the minimum element each pass and places it at the front.
Insertion Sort
SoonBuilds sorted array one element at a time. Great for small or nearly sorted data.
Merge Sort
SoonDivide and conquer. Splits, sorts halves, merges back. Guaranteed fast.
Quick Sort
SoonPicks a pivot, partitions around it. Fastest in practice. *O(n²) worst case.
Heap Sort
SoonBuilds a max-heap, extracts elements one by one. In-place, guaranteed O(n log n).
Searching
4 algorithms
Linear Search
Check every element until found. Works on unsorted data.
Binary Search
Requires sorted data. Halves the search space each step.
Depth-First Search
Goes deep before going wide. Uses stack or recursion.
Breadth-First Search
Explores level by level. Finds shortest path in unweighted graphs.
Trees
5 structures
Binary Tree
Each node has at most two children. Foundation for BST, heaps, and more.
AVL Tree
Self-balancing BST. Guarantees O(log n) by keeping height difference at most 1.
Red-Black Tree
Self-balancing BST used in most standard library maps. Less strict than AVL.
B-Tree
Multi-way tree optimized for disk access. Used in databases and filesystems.
Trie
Prefix tree. Fast string lookups. Used in autocomplete and spell checkers.
Graph Algorithms
5 algorithms
Dijkstra's
Shortest path from one source. Non-negative weights only.
A*
Dijkstra's with a heuristic. Faster in practice for pathfinding.
Kruskal's
Minimum spanning tree. Sort edges, add smallest that doesn't form a cycle.
Prim's
Minimum spanning tree. Grow tree from a vertex, always add cheapest edge.
Topological Sort
Linear ordering of DAG vertices. Used for build systems and task scheduling.
Dynamic Programming
4 problems
Fibonacci
Classic DP intro. Memoize overlapping subproblems.
Knapsack
Maximize value within weight limit. 0/1 and unbounded variants.
Longest Common Subsequence
Find longest shared subsequence between two strings. Used in diffs.
Coin Change
Minimum coins to make a target sum. Classic bottom-up DP.
Data Structures
| Structure | Access | Search | Insert | Delete |
|---|---|---|---|---|
| Array | O(1) | O(n) | O(n) | O(n) |
| Linked List | O(n) | O(n) | O(1) | O(1) |
| Stack | O(n) | O(n) | O(1) | O(1) |
| Queue | O(n) | O(n) | O(1) | O(1) |
| Hash Table | N/A | O(1)* | O(1)* | O(1)* |
| BST | O(log n) | O(log n) | O(log n) | O(log n) |
| Heap | O(1) | O(n) | O(log n) | O(log n) |
| Graph | N/A | O(V+E) | O(1) | O(V+E) |