A comprehensive collection of Data Structures and Algorithms implementations in C++ and Python. This repository serves as a learning resource and reference guide for coding interviews, competitive programming, and computer science fundamentals.
- Repository Structure
- Getting Started
- Data Structures
- Algorithms
- Problem Solutions
- Time & Space Complexity
- Contributing
- Resources
- License
DSA-ToolKit/
βββ README.md
βββ LICENSE
βββ .gitignore
βββ docs/
β βββ complexity-analysis.md
β βββ coding-patterns.md
β βββ interview-tips.md
βββ cpp/
β βββ data-structures/
β β βββ arrays/
β β βββ linked-lists/
β β βββ stacks/
β β βββ queues/
β β βββ trees/
β β βββ graphs/
β β βββ heaps/
β β βββ hash-tables/
β β βββ tries/
β βββ algorithms/
β β βββ sorting/
β β βββ searching/
β β βββ dynamic-programming/
β β βββ greedy/
β β βββ backtracking/
β β βββ divide-conquer/
β β βββ graph-algorithms/
β βββ problems/
β βββ leetcode/
β β βββ easy/
β β βββ medium/
β β βββ hard/
β βββ hackerrank/
β β βββ algorithms/
β β βββ data-structures/
β βββ codeforces/
β βββ codechef/
βββ python/
β βββ data-structures/
β β βββ arrays/
β β βββ linked-lists/
β β βββ stacks/
β β βββ queues/
β β βββ trees/
β β βββ graphs/
β β βββ heaps/
β β βββ hash-tables/
β β βββ tries/
β βββ algorithms/
β β βββ sorting/
β β βββ searching/
β β βββ dynamic-programming/
β β βββ greedy/
β β βββ backtracking/
β β βββ divide-conquer/
β β βββ graph-algorithms/
β βββ problems/
β βββ leetcode/
β β βββ easy/
β β βββ medium/
β β βββ hard/
β βββ hackerrank/
β β βββ algorithms/
β β βββ data-structures/
β βββ codeforces/
β βββ codechef/
βββ tests/
βββ cpp/
βββ python/
- Clone the repository:
git clone https://github.com/fa-code2/DSA-ToolKit
cd DSA-ToolKit- Arrays - Static and dynamic arrays, operations
- Linked Lists - Singly, doubly, and circular linked lists
- Stacks - LIFO operations, applications
- Queues - FIFO operations, circular queues, deques
- Trees - Binary trees, BST, AVL, Red-Black trees
- Graphs - Adjacency list/matrix, weighted/unweighted
- Heaps - Min/Max heaps, priority queues
- Hash Tables - Collision handling, hash functions
- Tries - Prefix trees, autocomplete implementation
- Bubble Sort, Selection Sort, Insertion Sort
- Merge Sort, Quick Sort, Heap Sort
- Counting Sort, Radix Sort, Bucket Sort
- Linear Search, Binary Search
- Ternary Search, Interpolation Search
- BFS, DFS traversals
- Shortest Path (Dijkstra, Bellman-Ford, Floyd-Warshall)
- Minimum Spanning Tree (Kruskal, Prim)
- Topological Sort
- Fibonacci, Knapsack problems
- Longest Common Subsequence
- Edit Distance, Coin Change
- Backtracking (N-Queens, Sudoku)
- Greedy algorithms
- Divide and Conquer
Problems are categorized by difficulty:
- Easy: Basic implementation and simple logic
- Medium: Moderate complexity, multiple approaches
- Hard: Advanced techniques, optimization required
Each solution includes:
- Problem statement
- Approach explanation
- Time/Space complexity analysis
- Multiple solutions (where applicable)
- Test cases
Each implementation includes complexity analysis:
| Data Structure | Access | Search | Insertion | Deletion | 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 | N/A | O(1) | O(1) | O(1) | O(n) |
| Binary Tree | O(n) | O(n) | O(n) | O(n) | O(n) |
| BST | O(log n) | O(log n) | O(log n) | O(log n) | O(n) |
We welcome contributions! Please follow these guidelines:
-
Fork the repository
-
Create a feature branch:
git checkout -b feature/new-algorithm -
Follow the coding standards:
- Use meaningful variable names
- Add comments explaining complex logic
- Include time/space complexity analysis
-
File naming convention:
- Use snake_case for file names
- Include no language extension (.cpp, .py)
- Example:
binary_search,quicksort
-
Code structure for each file:
For Platform Problems (LeetCode, HackerRank, etc.):
Python Template:
"""
Platform: LeetCode/HackerRank/CodeChef/Codeforces
Problem: [Problem Name]
Problem Number: [Platform specific number/ID]
URL: [Direct link to problem]
Difficulty: Easy/Medium/Hard
Time Complexity: O(?)
Space Complexity: O(?)
Author: [Your name]
Date: [Date]
Problem Description:
[Brief description of the problem]
Approach:
[Explain your solution approach]
"""
# ====================== PLATFORM SOLUTION ======================
class Solution:
def functionName(self, param1: type, param2: type) -> returnType:
# Your solution here - copy this directly to platform
pass
# ================================================================C++ Template:
/*
Platform: LeetCode/HackerRank/CodeChef/Codeforces
Problem: [Problem Name]
Problem Number: [Platform specific number/ID]
URL: [Direct link to problem]
Difficulty: Easy/Medium/Hard
Time Complexity: O(?)
Space Complexity: O(?)
Author: [Your name]
Date: [Date]
Problem Description:
[Brief description of the problem]
Approach:
[Explain your solution approach]
*/
// ====================== PLATFORM SOLUTION ======================
class Solution {
public:
returnType functionName(paramType param1, paramType param2) {
// Your solution here - copy this directly to platform
}
};
# ================================================================Example Implementation (LeetCode Problem):
Python Example:
"""
Platform: LeetCode
Problem: Maximum 69 Number
Problem Number: 1323
URL: https://leetcode.com/problems/maximum-69-number/
Difficulty: Easy
Time Complexity: O(n) where n is number of digits
Space Complexity: O(n) for string conversion
Author: YourName
Date: 2024-08-16
Problem Description:
Given a positive integer num consisting only of digits 6 and 9.
Return the maximum number you can get by changing at most one digit.
Approach:
Convert to string, find first '6' from left and replace with '9'.
This gives maximum value as we're changing the most significant digit.
"""
class Solution:
def maximum69Number(self, num: int) -> int:
s = str(num)
s = s.replace('6', '9', 1) # Replace only first occurrence
return int(s)File Naming Convention:
Platform_ProblemNumber_ProblemName
Examples:
- 1323_maximum_69_number (In leetcode)
- arrays_left_rotation (In hackerrank)
- Push to branch:
git push origin feature/new-algorithm - Submit a Pull Request
- Code follows naming conventions
- Includes complexity analysis
- Has test cases
- Documentation is clear
- No redundant implementations
- "Introduction to Algorithms" by Cormen, Leiserson, Rivest, and Stein
- "Algorithms" by Robert Sedgewick and Kevin Wayne
- "Cracking the Coding Interview" by Gayle McDowell
Track your learning progress:
- Arrays and Strings
- Linked Lists
- Stacks and Queues
- Trees and Binary Search Trees
- Heaps and Priority Queues
- Hash Tables
- Graphs
- Tries
- Sorting Algorithms
- Searching Algorithms
- Dynamic Programming
- Greedy Algorithms
- Backtracking
- Graph Algorithms
- String Algorithms
This project is licensed under the MIT License - see the LICENSE file for details.
- Contributors who have helped improve this repository
- The open-source community for inspiration and best practices
- Educational institutions and online platforms for algorithm resources
If you have any questions or suggestions, feel free to:
- Open an issue in this repository
- Reach out via [faaa367810@gmail.com]
- Connect on Linkedin
β Star this repo to stay motivated!
π‘ Remember: DSA is not hard, it's just practice over time β keep going!