A comprehensive collection of Data Structures and Algorithms implementations in multiple programming languages. This repository serves as a learning resource and reference for developers preparing for coding interviews, competitive programming, or simply wanting to understand fundamental algorithms.
dsa-snippets/
├── algorithms/
│ ├── sorting/
│ │ ├── bubble_sort/
│ │ ├── quick_sort/
│ │ ├── merge_sort/
│ │ └── ...
│ ├── searching/
│ │ ├── binary_search/
│ │ ├── linear_search/
│ │ └── ...
│ ├── graph/
│ │ ├── bfs/
│ │ ├── dfs/
│ │ ├── dijkstra/
│ │ └── ...
│ ├── dynamic_programming/
│ │ ├── fibonacci/
│ │ ├── knapsack/
│ │ └── ...
│ └── string/
│ ├── kmp/
│ ├── rabin_karp/
│ └── ...
├── DataStructure/
│ ├── LinkedList/
│ │ ├── DoubleLinkedList.cpp
│ │ └── LinkedListIntro.cpp
│ ├── Stack/
│ │ ├── Stack.cpp
│ │ └── Stack.java
│ ├── Queue/
│ │ ├── Queue.cpp
│ │ └── Queue.java
│ └── Tree/
│ └── TreeIntro.cpp
├── tests/
│ ├── algorithms/
│ └── data_structures/
├── docs/
│ ├── complexity_analysis.md
│ ├── language_guides/
│ └── algorithm_explanations/
├── .github/
│ ├── ISSUE_TEMPLATE/
│ └── workflows/
├── CONTRIBUTING.md
├── CODE_OF_CONDUCT.md
└── LICENSE
- Multi-language Support: Implementations in C++, Python, Java, JavaScript, Go, and more
- Comprehensive Testing: Unit tests for all implementations
- Detailed Documentation: Time/space complexity analysis and explanations
- Beginner Friendly: Clear comments and step-by-step explanations
- Interview Ready: Common coding interview problems and solutions
- C++:
DataStructure/Stack/Stack.cpp
- Complete stack implementation with push, pop, top operations - Java:
DataStructure/Stack/Stack.java
- Stack implementation using ArrayList - Features: LIFO (Last In First Out) principle, O(1) operations, comprehensive error handling
- C++:
DataStructure/Queue/Queue.cpp
- Complete queue implementation with enqueue, dequeue operations - Java:
DataStructure/Queue/Queue.java
- Queue implementation using ArrayList - Features: FIFO (First In First Out) principle, front/rear access, comprehensive error handling
-
Clone the repository
git clone https://github.com/yourusername/dsa-snippets.git cd dsa-snippets
-
Browse algorithms by category
# View sorting algorithms ls algorithms/sorting/ # View data structures ls data_structures/
-
Run an algorithm
# Example: Run Python quick sort python algorithms/sorting/quick_sort/quick_sort.py # Example: Compile and run C++ binary search g++ algorithms/searching/binary_search/binary_search.cpp -o binary_search ./binary_search
- C++ (.cpp)
- Python (.py)
- Java (.java)
- JavaScript (.js)
- Go (.go)
- Rust (.rs)
- C (.c)
We welcome contributions from developers of all skill levels! Here's how you can help:
- Add new algorithms - Implement algorithms in different languages
- Add data structures - Implement fundamental data structures
- Write tests - Add unit tests for existing implementations
- Improve documentation - Add explanations, complexity analysis
- Fix bugs - Report and fix issues in existing code
- Add examples - Provide usage examples and test cases
- Check our Issues page for open tasks
- Look for issues labeled
good first issue
orhelp wanted
- Read our Contributing Guidelines
- Fork the repository and create a new branch
- Make your changes and submit a pull request
algorithm
- New algorithm implementation neededdata-structure
- New data structure implementation neededbug
- Something isn't working correctlyenhancement
- Improvement to existing codedocumentation
- Documentation improvements neededtest
- Test cases neededgood first issue
- Good for newcomershelp wanted
- Extra attention needed
Thanks to all the amazing contributors who have helped build this repository!
Algorithm | Best Case | Average Case | Worst Case | Space |
---|---|---|---|---|
Bubble Sort | O(n) | O(n²) | O(n²) | O(1) |
Quick Sort | O(n log n) | O(n log n) | O(n²) | O(log n) |
Merge Sort | O(n log n) | O(n log n) | O(n log n) | O(n) |
Binary Search | O(1) | O(log n) | O(log n) | O(1) |
This project is licensed under the MIT License - see the LICENSE file for details.
If you find this repository helpful, please consider giving it a star! ⭐
- Create an Issue for bug reports or feature requests
- Start a Discussion for questions or ideas
Happy Coding! 🎉