Data Structures & Algorithms
A comprehensive collection of data structures and algorithms implemented in C , Go , Java , Python , Rust , and TypeScript .
Each implementation includes:
Detailed ASCII visual diagrams
Time & space complexity analysis
LeetCode problem mappings
Comprehensive unit tests
Language
Version
Build Tool
C
C11
gcc/make
Go
1.21+
go test
Java
17+
gradle
Python
3.10+
pytest
Rust
1.70+
cargo
TypeScript
ES2022
bun
dsa/
βββ by-language/ # Implementations organized by language
β βββ c/ # Complete C implementations
β βββ go/ # Complete Go implementations
β βββ java/ # Complete Java implementations
β βββ python/ # Complete Python implementations
β βββ rust/ # Complete Rust implementations
β βββ typescript/ # Complete TypeScript implementations
βββ by-topic/ # Cross-reference index by topic
β βββ arrays/ # Dynamic arrays, two pointers, sliding window
β βββ linked-lists/ # Singly/doubly linked lists
β βββ stacks/ # Stack operations, monotonic stacks
β βββ queues/ # Queues, deques, circular queues
β βββ hash-tables/ # Hash maps, bloom filters, caches
β βββ trees/ # BST, AVL, Red-Black, Trie, Segment Tree
β βββ heaps/ # Binary heaps, priority queues
β βββ graphs/ # Graph representations and algorithms
β βββ sorting/ # All sorting algorithms
β βββ searching/ # Binary search, two pointers, sliding window
β βββ strings/ # KMP, Rabin-Karp, Z-algorithm
β βββ dynamic-programming/ # DP patterns and problems
βββ COMPLEXITY.md # Master complexity cheat sheet
Structure
C
Go
Java
Python
Rust
TypeScript
Dynamic Array
β
β
β
β
β
β
Singly Linked List
β
β
β
β
β
β
Doubly Linked List
β
β
β
β
β
β
Stack
β
β
β
β
β
β
Queue
β
β
β
β
β
β
Deque
β
β
β
β
β
β
Circular Queue
β
β
β
β
β
β
Min/Max Stack
β
β
β
β
β
β
Monotonic Queue
β
β
β
β
β
β
Structure
C
Go
Java
Python
Rust
TypeScript
Binary Search Tree
β
β
β
β
β
β
AVL Tree
β
β
β
β
β
β
Red-Black Tree
β
β
β
β
β
β
B-Tree
β
β
β
β
β
β
Trie
β
β
β
β
β
β
Segment Tree
β
β
β
β
β
β
Fenwick Tree
β
β
β
β
β
β
Structure
C
Go
Java
Python
Rust
TypeScript
Hash Table
β
β
β
β
β
β
Bloom Filter
β
β
β
β
β
β
Structure
C
Go
Java
Python
Rust
TypeScript
Binary Heap
β
β
β
β
β
β
Priority Queue
β
β
β
β
β
β
Structure
C
Go
Java
Python
Rust
TypeScript
Adjacency List
β
β
β
β
β
β
Adjacency Matrix
β
β
β
β
β
β
Union-Find
β
β
β
β
β
β
Structure
C
Go
Java
Python
Rust
TypeScript
LRU Cache
β
β
β
β
β
β
LFU Cache
β
β
β
β
β
β
TTL Cache
β
β
β
β
-
β
Structure
C
Go
Java
Python
Rust
TypeScript
Skip List
β
β
β
β
β
β
Algorithm
C
Go
Java
Python
Rust
TypeScript
Bubble Sort
β
β
β
β
β
β
Selection Sort
β
β
β
β
β
β
Insertion Sort
β
β
β
β
β
β
Merge Sort
β
β
β
β
β
β
Quick Sort
β
β
β
β
β
β
Heap Sort
β
β
β
β
β
β
Counting Sort
β
β
β
β
β
β
Radix Sort
β
β
β
β
β
β
Algorithm
C
Go
Java
Python
Rust
TypeScript
Binary Search
β
β
β
β
β
β
Two Pointers
β
β
β
β
β
β
Sliding Window
β
β
β
β
β
β
Algorithm
C
Go
Java
Python
Rust
TypeScript
BFS
β
β
β
β
β
β
DFS
β
β
β
β
β
β
Dijkstra
β
β
β
β
β
β
Bellman-Ford
β
β
β
β
β
β
Floyd-Warshall
β
β
β
β
β
β
Prim's MST
β
β
β
β
β
β
Kruskal's MST
β
β
β
β
β
β
Topological Sort
β
β
β
β
β
β
Tarjan's SCC
β
β
β
β
β
β
Problem
C
Go
Java
Python
Rust
TypeScript
Fibonacci
β
β
β
β
β
β
Knapsack
β
β
β
β
β
β
LCS
β
β
β
β
β
β
LIS
β
β
β
β
β
β
Edit Distance
β
β
β
β
β
β
Coin Change
β
β
β
β
β
β
Algorithm
C
Go
Java
Python
Rust
TypeScript
KMP
β
β
β
β
β
β
Rabin-Karp
β
β
β
β
β
β
Z-Algorithm
β
β
β
β
β
β
cd by-language/c
make test
cd by-language/go
go test ./...
cd by-language/java
gradle test
cd by-language/python
pip install pytest
pytest tests/
cd by-language/rust
cargo test
cd by-language/typescript
bun install
bun test
# Install pre-commit and pre-push hooks
./.githooks/install.sh
Each implementation follows a consistent format:
/**
* [DATA STRUCTURE/ALGORITHM NAME]
*
* βββββββββββββββββββββββββββββββββββββββββ
* β VISUAL REPRESENTATION β
* βββββββββββββββββββββββββββββββββββββββββ
*
* COMPLEXITY:
* βββββββββββββ¬βββββββ¬ββββββββ
* β Operation β Time β Space β
* βββββββββββββΌβββββββΌββββββββ€
* β ... β O(?) β O(?) β
* βββββββββββββ΄βββββββ΄ββββββββ
*
* LEETCODE: #xxx Problem Name
*
* USE CASES: ...
*/
Each topic includes complexity analysis, common patterns, implementation tips, and related LeetCode problems:
Topic
Description
Arrays
Dynamic arrays, two pointers, sliding window, prefix sums
Linked Lists
Singly/doubly linked, fast/slow pointers, reversal
Stacks
LIFO operations, monotonic stacks, expression parsing
Queues
FIFO operations, deques, BFS patterns
Hash Tables
Hash maps, bloom filters, LRU/LFU caches
Trees
BST, AVL, Red-Black, B-Tree, Trie, Segment Tree
Heaps
Binary heaps, priority queues, top-K problems
Graphs
Representations, BFS, DFS, shortest paths, MST
Sorting
Comparison and non-comparison sorting algorithms
Searching
Binary search, two pointers, sliding window
Strings
KMP, Rabin-Karp, Z-algorithm, pattern matching
Dynamic Programming
DP patterns: linear, knapsack, string, grid, interval
MIT