Skip to content

notzenco/dsa

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

187 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

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 Requirements

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

Repository Structure

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

Data Structures

Linear

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 βœ“ βœ“ βœ“ βœ“ βœ“ βœ“

Trees

Structure C Go Java Python Rust TypeScript
Binary Search Tree βœ“ βœ“ βœ“ βœ“ βœ“ βœ“
AVL Tree βœ“ βœ“ βœ“ βœ“ βœ“ βœ“
Red-Black Tree βœ“ βœ“ βœ“ βœ“ βœ“ βœ“
B-Tree βœ“ βœ“ βœ“ βœ“ βœ“ βœ“
Trie βœ“ βœ“ βœ“ βœ“ βœ“ βœ“
Segment Tree βœ“ βœ“ βœ“ βœ“ βœ“ βœ“
Fenwick Tree βœ“ βœ“ βœ“ βœ“ βœ“ βœ“

Hashing

Structure C Go Java Python Rust TypeScript
Hash Table βœ“ βœ“ βœ“ βœ“ βœ“ βœ“
Bloom Filter βœ“ βœ“ βœ“ βœ“ βœ“ βœ“

Heaps

Structure C Go Java Python Rust TypeScript
Binary Heap βœ“ βœ“ βœ“ βœ“ βœ“ βœ“
Priority Queue βœ“ βœ“ βœ“ βœ“ βœ“ βœ“

Graphs

Structure C Go Java Python Rust TypeScript
Adjacency List βœ“ βœ“ βœ“ βœ“ βœ“ βœ“
Adjacency Matrix βœ“ βœ“ βœ“ βœ“ βœ“ βœ“
Union-Find βœ“ βœ“ βœ“ βœ“ βœ“ βœ“

Caches

Structure C Go Java Python Rust TypeScript
LRU Cache βœ“ βœ“ βœ“ βœ“ βœ“ βœ“
LFU Cache βœ“ βœ“ βœ“ βœ“ βœ“ βœ“
TTL Cache βœ“ βœ“ βœ“ βœ“ - βœ“

Advanced

Structure C Go Java Python Rust TypeScript
Skip List βœ“ βœ“ βœ“ βœ“ βœ“ βœ“

Algorithms

Sorting

Algorithm C Go Java Python Rust TypeScript
Bubble Sort βœ“ βœ“ βœ“ βœ“ βœ“ βœ“
Selection Sort βœ“ βœ“ βœ“ βœ“ βœ“ βœ“
Insertion Sort βœ“ βœ“ βœ“ βœ“ βœ“ βœ“
Merge Sort βœ“ βœ“ βœ“ βœ“ βœ“ βœ“
Quick Sort βœ“ βœ“ βœ“ βœ“ βœ“ βœ“
Heap Sort βœ“ βœ“ βœ“ βœ“ βœ“ βœ“
Counting Sort βœ“ βœ“ βœ“ βœ“ βœ“ βœ“
Radix Sort βœ“ βœ“ βœ“ βœ“ βœ“ βœ“

Searching

Algorithm C Go Java Python Rust TypeScript
Binary Search βœ“ βœ“ βœ“ βœ“ βœ“ βœ“
Two Pointers βœ“ βœ“ βœ“ βœ“ βœ“ βœ“
Sliding Window βœ“ βœ“ βœ“ βœ“ βœ“ βœ“

Graph

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 βœ“ βœ“ βœ“ βœ“ βœ“ βœ“

Dynamic Programming

Problem C Go Java Python Rust TypeScript
Fibonacci βœ“ βœ“ βœ“ βœ“ βœ“ βœ“
Knapsack βœ“ βœ“ βœ“ βœ“ βœ“ βœ“
LCS βœ“ βœ“ βœ“ βœ“ βœ“ βœ“
LIS βœ“ βœ“ βœ“ βœ“ βœ“ βœ“
Edit Distance βœ“ βœ“ βœ“ βœ“ βœ“ βœ“
Coin Change βœ“ βœ“ βœ“ βœ“ βœ“ βœ“

String

Algorithm C Go Java Python Rust TypeScript
KMP βœ“ βœ“ βœ“ βœ“ βœ“ βœ“
Rabin-Karp βœ“ βœ“ βœ“ βœ“ βœ“ βœ“
Z-Algorithm βœ“ βœ“ βœ“ βœ“ βœ“ βœ“

Quick Start

C

cd by-language/c
make test

Go

cd by-language/go
go test ./...

Java

cd by-language/java
gradle test

Python

cd by-language/python
pip install pytest
pytest tests/

Rust

cd by-language/rust
cargo test

TypeScript

cd by-language/typescript
bun install
bun test

Git Hooks (Optional)

# Install pre-commit and pre-push hooks
./.githooks/install.sh

Implementation Template

Each implementation follows a consistent format:

/**
 * [DATA STRUCTURE/ALGORITHM NAME]
 *
 * ╔═══════════════════════════════════════╗
 * β•‘         VISUAL REPRESENTATION         β•‘
 * β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
 *
 * COMPLEXITY:
 * β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”
 * β”‚ Operation β”‚ Time β”‚ Space β”‚
 * β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€
 * β”‚ ...       β”‚ O(?) β”‚ O(?)  β”‚
 * β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”˜
 *
 * LEETCODE: #xxx Problem Name
 *
 * USE CASES: ...
 */

Browse by Topic

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

License

MIT

About

data structures and algorithms

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors