A comprehensive collection of Data Structures and Algorithms implemented from scratch – covering everything from basic sorting to dynamic programming and graph traversal.
-
DSA Algorithms
-
📁 𝗗𝗮𝘁𝗮 𝗦𝘁𝗿𝘂𝗰𝘁𝘂𝗿𝗲𝘀
-
📁 Linked List
- Circular Linked List
- Circular Queue Using Linked List
- Doubly Linked List
- Queue Using Linked List
- Singly Linked List
- Stack Using Linked List
-
📁 Queue
- Circular Queue
- Queue
-
📁 Stack
- Stack
-
-
📁 𝗗𝘆𝗻𝗮𝗺𝗶𝗰 𝗣𝗿𝗼𝗴𝗿𝗮𝗺𝗺𝗶𝗻𝗴
- 0/1 Knapsack
- Factorial
- Fibonacci Using DP
- LCS Using Memoization
- LCS Using Recursion
- LCS Using Tabulation
-
📁 𝗚𝗿𝗮𝗽𝗵
- BFS
- DFS
- Dijkstra
- Kruskals Algorithm
- Prims Algorithm
-
📁 𝗚𝗿𝗲𝗲𝗱𝘆
- Fractional Knapsack
- Coin Change
-
📁 𝗦𝗲𝗮𝗿𝗰𝗵𝗶𝗻𝗴
- Binary Search Using Given Array
- Binary Search
- Linear Search
- Ternary Search Using Given Array
- Ternary Search
-
📁 𝗦𝗼𝗿𝘁𝗶𝗻𝗴
- Bubble Sort
- Insertion Sort
- Merge Sort
- Quick Sort
- Selection Sort
-
| Structure | Variants |
|---|---|
| Linked List | Singly, Doubly, Circular, Stack / Queue / Circular Queue using LL |
| Stack | Array-based, Linked List-based |
| Queue | Simple Queue, Circular Queue, Linked List-based |
| Algorithm | Time (Best) | Time (Average) | Time (Worst) | Space |
|---|---|---|---|---|
| Bubble Sort | O(n) | O(n²) | O(n²) | O(1) |
| Selection Sort | O(n²) | O(n²) | O(n²) | O(1) |
| Insertion Sort | O(n) | O(n²) | O(n²) | O(1) |
| Merge Sort | O(n log n) | O(n log n) | O(n log n) | O(n) |
| Quick Sort | O(n log n) | O(n log n) | O(n²) | O(log n) |
| Algorithm | Time (Best) | Time (Worst) | Requires Sorted? |
|---|---|---|---|
| Linear Search | O(1) | O(n) | ❌ No |
| Binary Search | O(1) | O(log n) | ✅ Yes |
| Ternary Search | O(1) | O(log₃ n) | ✅ Yes |
| Algorithm | Use Case |
|---|---|
| BFS | Shortest path in unweighted graph, level-order traversal |
| DFS | Cycle detection, topological sort, path finding |
| Dijkstra | Shortest path in weighted graph (non-negative weights) |
| Kruskal's | Minimum Spanning Tree – edge-based greedy approach |
| Prim's | Minimum Spanning Tree – vertex-based greedy approach |
| Problem | Approach |
|---|---|
| 0/1 Knapsack | Tabulation |
| Fibonacci | DP (memoized) |
| Factorial | DP |
| LCS | Recursion, Memoization, Tabulation |
| Problem | Strategy |
|---|---|
| Fractional Knapsack | Sort by value / weight ratio |
| Coin Change | Always pick largest denomination first |
Contributions are welcome! Feel free to open an issue or submit a pull request if you'd like to add new algorithms or improve existing implementations.
