Algorithms and Data Structures in Python
Create virtual env and install Python packages:
source configure.shpylint srcpytest# build
mkdocs build
# serve
mkdocs serve
# open docs in browser
open http://127.0.0.1:8000- Arrays & Lists
- Dynamic arrays
- Linked lists (singly, doubly, circular)
- Stacks and Queuess (stack, queue, deque)
- Trees
- Binary tree
- Binary search tree
- Heap (min, max)
- TODO: AVL tree
- TODO: Red-black tree
- Hash Tables
- Hash map
- Hash set
- Graphs
- Adjacency list representation
- Adjacency matrix representation
- Undirected graph
- Directed graph
- Strings
- Trie / PrefixTree
- SuffixTree
- SuffixArray
-
Sorting
- Bubble sort, Selection sort, Insertion sort
- Merge sort, Quick sort
- Radix sort, Counting sort
- Heap sort
-
Searching
- Linear search, Binary search
-
Hashing
- Polynomial Rolling Hash (for strings)
- FNV-1a Hash
- Simple Multiplicative Hash
- Jenkins One-at-a-Time Hash
- DJB2 Hash
- SDBM Hash
- MurmurHash3 (simplified version)
-
Graph Algorithms
- Depth-first search (DFS)
- Breadth-first search (BFS)
- Floyd-Warshall shortest path
- Dijkstra shortest path
- TODO: Bellman-Ford shortest path
- TODO: Minimum spanning tree (Kruskal's)
- TODO: Minimum spanning tree (Prim's)
-
Dynamic Programming
- Fibonacci sequence
- TODO: Knapsack problem
-
Strings
- Palindrome Detection
- Edit distance
- Autocomplete
- Substring Search / Find all occurrences of a substring
- Longest Common Substring
- Longest Repeated Substring
- TODO: Longest Common Subsequence
- TODO: Pattern Matching
- TODO: Compression
- TODO: Regex
graph TD
%% Pattern Detection
subgraph "Pattern Detection"
Palindrome[Palindrome Detection]
end
Palindrome --> Array
Palindrome --> DynamicProgramming
%% Data Structures
subgraph "Data Structures"
Array
end
%% Algorithms
subgraph Algorithms
DynamicProgramming
end
graph TD
%% Transformation
subgraph Transformation
EditDist[Edit Distance]
end
EditDist --> DynamicProgramming
EditDist --> Arrays
%% Data Structures
subgraph "Data Structures"
Arrays
end
%% Algorithms
subgraph Algorithms
DynamicProgramming
end
- Autocomplete
- Substring Search
graph TD
%% Indexing
subgraph "Indexing / Searching"
Autocomplete
SubstringSearch[Substring Search]
end
Autocomplete --> Trie
SubstringSearch --> SuffixTree
SubstringSearch --> SuffixArray
%% Data Structures
subgraph "Data Structures (Advanced)"
SuffixTree
SuffixArray
end
SuffixTree --> Array
SuffixArray --> Array
SuffixArray --> Sorting
SuffixArray --> BinarySearch
%% Data Structures
subgraph "Data Structures"
Array
Trie[Trie / PrefixTree]
end
%% Algorithms
subgraph Algorithms
Sorting
BinarySearch
end
-
Longest Common Substring
-
Longest Repeated Substring
-
TODO: Longest Common Subsequence
graph TD
%% Substring and Subsequence Analysis
subgraph "Substring Analysis"
LCS[Longest Common Substring]
LCSeq[Longest Common Subsequence]
LRS[Longest Repeated Substring]
end
LCS --> DynamicProgramming
LCS --> SuffixTree
LCS --> SuffixArray
LCSeq --> DynamicProgramming
LRS --> SuffixTree
LRS --> SuffixArray
%% Data Structures
subgraph "Data Structures (Advanced)"
SuffixTree
SuffixArray
end
SuffixTree --> Array
SuffixArray --> Array
SuffixArray --> Sorting
SuffixArray --> BinarySearch
%% Data Structures
subgraph "Data Structures"
Array
end
%% Algorithms
subgraph Algorithms
DynamicProgramming
Sorting
BinarySearch
end
graph TD
%% Pattern Matching and Searching
subgraph "Pattern Matching"
KMP["Knuth-Morris-Pratt (KMP)"]
RabinKarp[Rabin-Karp]
BoyerMoore[Boyer-Moore]
Naive[Naive]
AhoCorasick[Aho-Corasick]
end
KMP --> Arrays
RabinKarp --> Arrays
RabinKarp --> Hashing
BoyerMoore --> Arrays
Naive --> Arrays
AhoCorasick --> Trie
AhoCorasick --> FiniteAutomata
%% Data Structures
subgraph "Data Structures"
Arrays
Trie[Trie / PrefixTree]
end
%% Algorithms
subgraph Algorithms
Hashing
FiniteAutomata
end
graph TD
%% Compression
subgraph Compression
RLE[Run-Length Encoding]
Huffman[Huffman Coding]
end
RLE --> Array
Huffman --> PriorityQueue
Huffman --> BinaryTree
Huffman --> Greedy
%% Data Structures
subgraph "Data Structures"
Array
PriorityQueue
BinaryTree
end
%% Algorithms
subgraph Algorithms
Greedy["Greedy Huffman Tree Construction"]
end
graph TD
%% Regex
subgraph Regex
RegexAlg[Regex Matching]
end
Regex --> Array
Regex --> FiniteAutomata
Regex --> DynamicProgramming
%% Data Structures
subgraph "Data Structures"
Array
end
%% Algorithms
subgraph Algorithms
DynamicProgramming
FiniteAutomata
end
# On macOS and Linux.
curl -LsSf https://astral.sh/uv/install.sh | sh
echo 'PATH="$HOME/.local/bin":$PATH' >> $HOME/bash_profile# install python
uv python list
uv python install 3.14
# init project
uv init
uv venv .venv
source .venv/bin/activate# app
uv add <package>
# test and lint
uv add --dev pytest pylint