Skip to content

Open-source collection of optimized Data Structures and Algorithms with clean code, thorough documentation, and step-by-step explanations. Features implementations in both C++ and Python, covering everything from basic arrays to advanced graph algorithms.

License

Notifications You must be signed in to change notification settings

fa-code2/DSA-ToolKit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

25 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Data Structures and Algorithms (DSA)

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.

Table of Contents

πŸ“ Repository Structure

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/

Getting Started

Installation

  1. Clone the repository:
git clone https://github.com/fa-code2/DSA-ToolKit
cd DSA-ToolKit

Data Structures

Basic Data Structures

  • Arrays - Static and dynamic arrays, operations
  • Linked Lists - Singly, doubly, and circular linked lists
  • Stacks - LIFO operations, applications
  • Queues - FIFO operations, circular queues, deques

Advanced Data Structures

  • 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

Algorithms

Sorting Algorithms

  • Bubble Sort, Selection Sort, Insertion Sort
  • Merge Sort, Quick Sort, Heap Sort
  • Counting Sort, Radix Sort, Bucket Sort

Searching Algorithms

  • Linear Search, Binary Search
  • Ternary Search, Interpolation Search

Graph Algorithms

  • BFS, DFS traversals
  • Shortest Path (Dijkstra, Bellman-Ford, Floyd-Warshall)
  • Minimum Spanning Tree (Kruskal, Prim)
  • Topological Sort

Dynamic Programming

  • Fibonacci, Knapsack problems
  • Longest Common Subsequence
  • Edit Distance, Coin Change

Other Important Algorithms

  • Backtracking (N-Queens, Sudoku)
  • Greedy algorithms
  • Divide and Conquer

Problem Solutions

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

⏱️ Time & Space Complexity

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)

Contributing

We welcome contributions! Please follow these guidelines:

  1. Fork the repository

  2. Create a feature branch: git checkout -b feature/new-algorithm

  3. Follow the coding standards:

    • Use meaningful variable names
    • Add comments explaining complex logic
    • Include time/space complexity analysis
  4. File naming convention:

    • Use snake_case for file names
    • Include no language extension (.cpp, .py)
    • Example: binary_search, quicksort
  5. 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)

  1. Push to branch: git push origin feature/new-algorithm
  2. Submit a Pull Request

Code Review Checklist

  • Code follows naming conventions
  • Includes complexity analysis
  • Has test cases
  • Documentation is clear
  • No redundant implementations

πŸ“š Resources

Books

  • "Introduction to Algorithms" by Cormen, Leiserson, Rivest, and Stein
  • "Algorithms" by Robert Sedgewick and Kevin Wayne
  • "Cracking the Coding Interview" by Gayle McDowell

Online Platforms

Visualization Tools

πŸ“ˆ Progress Tracking

Track your learning progress:

Data Structures

  • Arrays and Strings
  • Linked Lists
  • Stacks and Queues
  • Trees and Binary Search Trees
  • Heaps and Priority Queues
  • Hash Tables
  • Graphs
  • Tries

Algorithms

  • Sorting Algorithms
  • Searching Algorithms
  • Dynamic Programming
  • Greedy Algorithms
  • Backtracking
  • Graph Algorithms
  • String Algorithms

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • Contributors who have helped improve this repository
  • The open-source community for inspiration and best practices
  • Educational institutions and online platforms for algorithm resources

Contact

If you have any questions or suggestions, feel free to:


⭐ Star this repo to stay motivated!

πŸ’‘ Remember: DSA is not hard, it's just practice over time β€” keep going!

About

Open-source collection of optimized Data Structures and Algorithms with clean code, thorough documentation, and step-by-step explanations. Features implementations in both C++ and Python, covering everything from basic arrays to advanced graph algorithms.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •