A comprehensive learning resource for implementing common data structures and algorithms in Python
This repository was started in 2017 with a simple goal: to create a comprehensive, well-documented collection of Data Structures and Algorithms implementations in Python. Whether you're preparing for technical interviews, learning CS fundamentals, or just brushing up on your algo skills, this repo serves as a practical reference.
- ๐ Educational: Each implementation is well-commented and easy to understand
- ๐ Multiple Solutions: Different approaches to the same problem (brute force, optimized, etc.)
- ๐ Interview Ready: Solutions for common technical interview questions
- ๐ Practical: Standalone scripts that can be run and modified
This is an open-source learning project! We welcome contributions from everyone:
- Found a bug? Open an issue
- Have a better solution? Submit a pull request
- Want to add new algorithms? Contributions are always appreciated!
- Have learning notes? Share them with the community
- Python 3.6 or higher
- Basic understanding of Python syntax
Most scripts in this repository are standalone and can be executed directly:
# Run any Python script
python3 Arrays/Anagram_Check_Sorted_Sol.py
# Or run from the repo root
python3 Sorting/BubbleSortImple.py.
โโโ Arrays/ # ๐ค Array-based problems and algorithms
โโโ LinkedLists/ # ๐ Singly and Doubly Linked Lists
โโโ Stacks/ # ๐ Stack implementations and applications
โโโ Queues/ # ๐ฆ Queue implementations (FIFO)
โโโ deque/ # ๐ Double-ended queue
โโโ Trees/ # ๐ณ Binary Trees, BSTs, Heaps, and Traversals
โโโ Sorting/ # ๐ Common sorting algorithms
โโโ Recursion/ # ๐ Recursive problems and Dynamic Programming
โโโ GraphAlgorithms/ # ๐บ๏ธ Graph traversal (BFS, DFS) and pathfinding
โโโ Error-debug/ # โ ๏ธ Error handling and debugging examples
โโโ README.md # This file
Common array-based algorithms and manipulations.
- Anagram Check: Sorted & Manual solutions
- Array Pair Sum: Find pairs that sum to k
- Find Missing Element: XOR, Brute Force, Hash Table, Sum approaches
Implementations and problems involving linked structures.
- Singly Linked List & Doubly Linked List
- Cycle Detection: Detect cycles using two pointers
- Reverse Linked List: In-place reversal
- Nth to Last Node: Find the n-th node from the end
LIFO (Last-In-First-Out) data structures.
- Stack Implementation: Basic operations (push, pop, peek)
- Balanced Parentheses: Check for balanced brackets
FIFO (First-In-First-Out) data structures.
- Queue Implementation: Basic operations (enqueue, dequeue)
- Queue with Two Stacks: Implementing FIFO using LIFO structures
Double-ended queue operations.
- Deque Implementation: Operations at both ends
Hierarchical data structures.
- Binary Search Tree: Complete BST implementation
- Binary Heap: Min-heap implementation
- BST Validation: Multiple solutions
- Tree Traversals: Level order (BFS) printing
- Trim BST: Keep nodes within a range
- Binary Search: Iterative & Recursive approaches
Algorithms for arranging elements in order.
- Bubble Sort - O(nยฒ)
- Selection Sort - O(nยฒ)
- Insertion Sort - O(nยฒ)
- Shell Sort - O(n log n)
- Merge Sort - O(n log n)
- Quick Sort - O(n log n) average
Solving problems by breaking them into smaller sub-problems.
- Fibonacci Sequence: Iterative, Recursive & DP solutions
- Coin Change Problem: Recursive & DP approaches
- String Operations: Reverse & Permutations
- Word Split: Dynamic Programming solution
Algorithms for graph traversal and pathfinding.
- Adjacency List: Graph ADT
- Breadth First Search (BFS): Word Ladder problem
- Depth First Search (DFS): General & Knight's Tour
Most scripts in this repository are standalone. You can run them using the Python 3 interpreter:
python3 path/to/script.pyExample:
python3 Sorting/BubbleSortImple.py| Topic | Easy | Medium | Hard |
|---|---|---|---|
| Arrays | Anagram Check | Array Pair Sum | Find Missing Element |
| Linked Lists | Singly LL | Cycle Detection | Reverse LL |
| Trees | Binary Search | BST Validation | Trim BST |
| Sorting | Bubble Sort | Merge Sort | Quick Sort |
| DP | Fibonacci | Coin Change | Word Split |
New to DSA? Follow this recommended order:
- Start with Arrays - Fundamental data structure
- Learn Sorting - Essential for interviews
- Study Linked Lists - Understanding pointers/references
- Master Stacks & Queues - Core data structures
- Explore Trees - Most interview questions
- Dive into Recursion & DP - Advanced problem solving
- Finish with Graphs - Complex algorithms
- Add more graph algorithms (Dijkstra, Bellman-Ford)
- Include complexity analysis for each solution
- Add interactive examples/visualizations
- Create a difficulty level classification
- Add more test cases
- Create beginner-friendly guides
This project is licensed under the MIT License - see the LICENSE file for details.
Copyright (c) 2017 - 2026 Pradeep K. Pant
Pradeep K. Pant
- Started: 2017
- Python enthusiast | Algorithm lover | Open source advocate
If this repository helped you learn or prepare for interviews, please consider:
- โญ Starring the repository
- ๐ค Contributing improvements
- ๐ข Sharing with others learning DSA
- ๐ฌ Giving feedback
Happy Learning! ๐