π― About This Repository
This repository demonstrates hands-on mastery of fundamental computer science concepts through clean, well-documented Python implementations. Unlike library-dependent code, every data structure and algorithm here is built from scratch to showcase deep understanding of how things work under the hood.
Category
Count
Data Structures
10+
Algorithms
9+
Interactive Notebooks
15+
Practice Exercises
20+
Lines of Code
2,500+
β
No External Dependencies β Pure Python implementations
β
Interview-Ready β Covers FAANG-style questions
β
Well-Documented β Clear explanations & comments
β
Interactive β Jupyter notebooks for step-by-step learning
β
Practical Examples β Real-world use cases
π¦ Linear Structures
Structure
Implementation
Key Operations
Notebook
Singly Linked List
LinkedList.py
Insert, Delete, Traverse, Search
β
Doubly Linked List
DoublyLinkedList.py
Bidirectional traversal, Insert at any position
β
Stack
Stack.ipynb
Push, Pop, Peek, IsEmpty
π
Queue
Queue.ipynb
Enqueue, Dequeue, Producer-Consumer pattern
π
ποΈ Hash-Based Structures
π³ Tree Structures
Structure
Implementation
Key Operations
Notebook
General Tree
Tree.py
Add child, Get level, Print hierarchy
π
Binary Search Tree
BinarySearchTree.py
Insert, Delete, Search, Min/Max, Traversals
π
π Graph Structures
Structure
Implementation
Key Operations
Notebook
Directed Graph
Graph.py
Adjacency List, Find all paths, Shortest path
π
Algorithm
Time Complexity
Implementation
Description
Binary Search
O(log n)
BinarySearch.py
Iterative & Recursive implementations
Binary Search (Find All)
O(log n + k)
BinarySearch-excercise.py
Find all occurrences of duplicates
Algorithm
Best
Average
Worst
Space
Stable
Bubble Sort
O(n)
O(nΒ²)
O(nΒ²)
O(1)
β
Quick Sort
O(n log n)
O(n log n)
O(nΒ²)
O(log n)
β
Merge Sort
O(n log n)
O(n log n)
O(n log n)
O(n)
β
Insertion Sort
O(n)
O(nΒ²)
O(nΒ²)
O(1)
β
Selection Sort
O(nΒ²)
O(nΒ²)
O(nΒ²)
O(1)
β
Shell Sort
O(n log n)
O(n^1.25)
O(nΒ²)
O(1)
β
Algorithm
Implementation
Use Case
Depth-First Search (DFS)
dfs.py
Path finding, Cycle detection, Topological sort
Breadth-First Search (BFS)
bfs.py
Shortest path (unweighted), Level-order traversal
π Complexity Analysis Cheat Sheet
Data Structure
Access
Search
Insert
Delete
Space
Array
O(1)
O(n)
O(n)
O(n)
O(n)
Linked List
O(n)
O(n)
O(1)*
O(1)*
O(n)
Stack
O(n)
O(n)
O(1)
O(1)
O(n)
Queue
O(n)
O(n)
O(1)
O(1)
O(n)
Hash Table
β
O(1)β
O(1)β
O(1)β
O(n)
Binary Search Tree
O(log n)β
O(log n)β
O(log n)β
O(log n)β
O(n)
Graph (Adj. List)
O(V)
O(V)
O(1)
O(E)
O(V+E)
*At known position Β Β β Average case
Each topic includes hands-on exercises with solutions:
π· Arrays β Manipulation, searching, sorting
Finding max/min elements
Marvel heroes data processing
Odd/even number separation
Expense tracking system
π· Linked Lists β Pointer manipulation mastery
Implement singly linked list from scratch
Add doubly linked list functionality
Insert/delete at any position
Reverse a linked list
π· Hash Tables β Collision handling strategies
Weather data analysis with hash tables
Word occurrence counter (poem analysis)
Stock price lookup system
Custom hash function design
π· Stacks β LIFO applications
String reversal
Balanced parentheses checker ()[]{}
Expression evaluation
π· Queues β FIFO applications
Binary number generator
Food ordering system (with threading!)
Producer-consumer pattern
π· Trees β Hierarchical data mastery
Management hierarchy visualization
Location hierarchy system
BST operations (CRUD)
Tree traversals (Inorder, Preorder, Postorder)
π· Graphs β Network algorithms
Flight route planning system
Find all paths between nodes
Shortest path (by hops)
DFS/BFS implementations
Python 3.10+
Jupyter Notebook (optional, for interactive notebooks)
# Clone the repository
git clone https://github.com/mrlibelula/python-algorithms.git
cd python-algorithms
# (Optional) Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install Jupyter for interactive notebooks
pip install jupyter
# Launch Jupyter
jupyter notebook
# Run standalone Python implementations
python data_structures/BinarySearchTree.py
python data_structures/Graph.py
python data_structures/HashTableChaining.py
# Or explore interactively
jupyter notebook data_structures/
python-algorithms/
β
βββ π data_structures/ # Main implementations
β βββ π LinkedList.py # Singly linked list
β βββ π DoublyLinkedList.py # Doubly linked list
β βββ π HashTableChaining.py # Hash table (chaining)
β βββ π HashTableProbing.py # Hash table (linear probing)
β βββ π BinarySearchTree.py # BST with traversals
β βββ π Tree.py # General tree
β βββ π Graph.py # Directed graph
β βββ π *.ipynb # Interactive notebooks
β
βββ π search_algorithms/ # Search & sort algorithms
β βββ π BinarySearch.py # Iterative binary search
β βββ π BubbleSort.ipynb # Sorting notebook
β βββ π *.ipynb # More notebooks
β
βββ π _resources/ # Learning materials
β βββ π algorithms/ # Algorithm exercises & solutions
β β βββ BinarySearch/
β β βββ BubbleSort/
β β βββ QuickSort/
β β βββ MergeSort/
β β βββ InsertionSort/
β β βββ SelectionSort/
β β βββ ShellSort/
β β βββ DepthFirstSearch/
β β βββ BreadthFirstSearch/
β β
β βββ π data_structures/ # Data structure exercises
β βββ Arrays/
β βββ LinkedList/
β βββ HashTable/
β βββ Stack/
β βββ Queue/
β βββ Tree/
β βββ Graph/
β
βββ π TECHNICAL_OVERVIEW.md # Detailed technical documentation
βββ π README.md # You are here!
πΌ Technical Skills Demonstrated
Type hints & annotations
Magic methods (__setitem__, __getitem__)
Collections module (deque)
Multi-threading
Big O complexity analysis
Recursion & iteration
Pointer manipulation
Algorithm design patterns
Clean, readable code
Modular architecture
Interactive documentation
Test-driven exercises
π Recommended order for studying this repository:
1. Arrays β Foundation of sequential data
β
2. Linked Lists β Understanding pointers/references
β
3. Hash Tables β Key-value storage & collision handling
β
4. Stacks & Queues β LIFO/FIFO abstract data types
β
5. Trees & BST β Hierarchical data organization
β
6. Graphs β Network modeling with DFS/BFS
β
7. Sorting β Comparison-based algorithms
β
8. Searching β Efficient data retrieval
Contributions, issues, and feature requests are welcome! Feel free to check the issues page .
Built with π by libe.dev
β Star this repository if you found it helpful!