An organized, production-quality repository dedicated to learning and mastering Data Structures and Algorithms (DSA) using Python. Featuring clean implementations, step-by-step dry-run traces, mathematical analyses, and Big-O complexity breakdowns.
Curriculum • Repository Structure • Complexity Cheat Sheet • Getting Started • Contributing
This repository is designed as both a study companion and an engineering reference. Every algorithm is provided with:
- 💡 Clean, PEP 8 Compliant Python Code with type annotations and docstrings.
- 📝 In-depth Theoretical Notes breaking down intuition, edge cases, and dry-runs.
- ⏱️ Time & Space Complexity Proofs (Best, Average, and Worst cases).
- 🧪 Interactive Demonstrations ready to execute directly from the terminal.
- Bubble Sort (Code | Notes)
- Selection Sort (Code | Notes)
- Insertion Sort (Code | Notes)
- Merge Sort (Upcoming)
- Quick Sort (Upcoming)
- Linear Search (Upcoming)
- Binary Search (Upcoming)
- Asymptotic Notation (
$\mathcal{O}$ ,$\Omega$ ,$\Theta$ ) (Notes) - Iteration & Swap Calculation Formulas (Notes (Bubble Sort) | Notes (Selection Sort) | Notes (Insertion Sort))
- Time & Space Complexity Proofs & Common Patterns (Notes)
- Arrays & Dynamic Arrays
- Stack (Array & Linked List implementations)
- Queue (Simple, Circular, & Deque)
- Linked List (Singly, Doubly, & Circular)
- Trees & Binary Search Trees (BST)
- Graphs & Traversals (BFS / DFS)
- Hashing & Hash Maps
| Algorithm | Best Case | Average Case | Worst Case | Space Complexity | Stable? | In-Place? |
|---|---|---|---|---|---|---|
| Bubble Sort | Yes | Yes | ||||
| Selection Sort | No | Yes | ||||
| Insertion Sort | Yes | Yes | ||||
| Merge Sort | Yes | No | ||||
| Quick Sort | No | Yes |
DSA_Using_Python/
│
├── .gitignore # Ignores bytecode, caches, and environment configs
├── BubbleSort.md # Theoretical foundation, dry-runs & Bubble Sort notes
├── complexity.md # Comprehensive Time & Space Complexity analysis guide
├── InsertionSort.md # Insertion Sort theory, pass traces & complexity notes
├── LICENSE # MIT Open-Source License
├── README.md # Repository documentation and navigation guide
├── SelectionSort.md # Selection Sort theory, pass traces & complexity notes
│
└── Programs/ # Executable Python implementations
├── bubble_sort.py # Bubble Sort (PEP 8 standard naming)
├── BubleSort.py # Bubble Sort implementation
├── insertion_sort.py # Insertion Sort (PEP 8 standard naming)
├── InsertionSort.py # Insertion Sort implementation
├── selection_sort.py # Selection Sort (PEP 8 standard naming)
└── SelectionSort.py # Selection Sort implementation
- Python 3.8 or higher installed on your system.
git clone https://github.com/AnilYadav17/DSA_Using_Python.git
cd DSA_Using_PythonEach program contains an interactive demo mode:
# Run Bubble Sort demo
python3 Programs/bubble_sort.py
# Run Selection Sort demo
python3 Programs/selection_sort.py
# Run Insertion Sort demo
python3 Programs/insertion_sort.pyExample Run (Bubble Sort):
==================================================
BUBBLE SORT DEMO
==================================================
Enter numbers separated by space (or press Enter for default demo): 64 34 25 12 22 11 90
Original Array : [64, 34, 25, 12, 22, 11, 90]
Sorted Array : [11, 12, 22, 25, 34, 64, 90]
Example Run (Selection Sort):
==================================================
SELECTION SORT DEMO
==================================================
Enter numbers separated by space (or press Enter for default demo): 10 5 8 2 1 3
Original Array : [10, 5, 8, 2, 1, 3]
Sorted Array : [1, 2, 3, 5, 8, 10]
Example Run (Insertion Sort):
==================================================
INSERTION SORT DEMO
==================================================
Enter numbers separated by space (or press Enter for default demo): 12 11 13 5 6
Original Array : [12, 11, 13, 5, 6]
Sorted Array : [5, 6, 11, 12, 13]
All implementations in this repository follow strict coding principles:
- Type Hinting: Using Python's
typingmodule for clear parameter and return types. - Documentation: Google/Sphinx style docstrings describing time and space complexities.
- Modularity: Algorithms are encapsulated in reusable functions with
__main__entry points.
Contributions, issues, and feature requests are welcome!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/NewAlgorithm) - Commit your Changes (
git commit -m 'Add Selection Sort algorithm') - Push to the Branch (
git push origin feature/NewAlgorithm) - Open a Pull Request
Distributed under the MIT License. See LICENSE for more details.