Welcome to DSA! ๐ This repository is your go-to resource for learning and mastering Data Structures and Algorithms (DSA) through clean, well-documented C++ implementations. It includes core DSA concepts and solutions to popular LeetCode-style problems, making it perfect for students, coding enthusiasts, and anyone preparing for technical interviews. Whether you're a beginner or sharpening your skills, this repo has something for you! ๐ป
- Features
- Folder Structure
- Tech Stack
- Installation
- Usage
- Topics Covered
- Contributing
- License
- Roadmap
- Acknowledgements
- Comprehensive DSA Implementations: Covers essential data structures and algorithms with clear, optimized C++ code. ๐ง
- LeetCode-Style Problems: Solutions to common algorithmic problems to boost your problem-solving skills. ๐ฏ
- Well-Organized Files: Each
.cppfile is named after the specific data structure or algorithm it implements. ๐ - Beginner-Friendly: Easy-to-understand code with comments for learning and reference. ๐
- Ready-to-Run: Simple compilation instructions to get you started quickly. โก
The repository is organized such that each .cpp file contains a specific data structure implementation or algorithm solution. Filenames are descriptive, matching the topic or problem (e.g., bfs_traversal.cpp, two_sum.cpp). All files are located in the root directory for simplicity.
DSA/
โโโ adjacency_list.cpp # Graph representation using adjacency list
โโโ adjacency_matrix.cpp # Graph representation using adjacency matrix
โโโ arrays.cpp # Array-based operations
โโโ asd.cpp # Additional data structure implementations
โโโ avl _trees_rotations.cpp # AVL tree with rotations
โโโ avl_trees.cpp # AVL tree implementation
โโโ bellman_ford_algo.cpp # Bellman-Ford shortest path algorithm
โโโ bfs_traversal.cpp # Breadth-First Search for graphs
โโโ binary_search_trees.cpp # Binary Search Tree operations
โโโ binary_tree.cpp # Binary Tree implementation
โโโ bs.cpp # Binary search algorithm
โโโ bucket_array.cpp # Hash table with bucket arrays
โโโ circular_linked_lists.cpp # Circular linked list operations
โโโ cycle_linkedlist.cpp # Detect cycle in linked list
โโโ dfs_traversal.cpp # Depth-First Search for graphs
โโโ dijkstars_algo.cpp # Dijkstraโs shortest path algorithm
โโโ doubly_circular_linked_lists.cpp # Doubly circular linked list
โโโ doubly_linked_lists.cpp # Doubly linked list operations
โโโ dsa_final.cpp # Comprehensive DSA implementation
โโโ final.cpp # Final implementation file
โโโ hash_map.cpp # Hash map implementation
โโโ heaps.cpp # Heap data structure and operations
โโโ largest_rectangle_histrogram,next_smallest_largest_element.cpp # Histogram problems
โโโ longest_substring_without_repeating.cpp # Longest substring without repeating chars
โโโ next&prev_smallest element.cpp # Next/previous smaller element
โโโ pattern.cpp # Pattern matching algorithm
โโโ prims_algo.cpp # Primโs minimum spanning tree algorithm
โโโ product_ofarray_exceptself.cpp # Product of array except self
โโโ queues.cpp # Queue implementation
โโโ queues_using_stacks.cpp # Queue using stacks
โโโ reverse_linkedLIst.cpp # Reverse a linked list
โโโ singly_linked_lists.cpp # Singly linked list operations
โโโ stack.cpp # Stack implementation
โโโ two_sum.cpp # Two Sum problem solution
โโโ validat_BST.cpp # Validate Binary Search Tree
โโโ valid_parenthesis.cpp # Valid parenthesis checker
โโโ vectors.cpp # Vector operations in C++
โโโ README.md # Project documentation
Total Files: 37 C++ implementations + 1 README
- C++: Primary language for all implementations (C++11 or later recommended).
- Compiler: Use
g++or any standard C++ compiler (e.g., GCC, Clang, MSVC). - No External Libraries: Pure C++ with standard libraries (
<vector>,<queue>,<stack>, etc.).
Compilation Instructions:
- Ensure you have a C++ compiler installed (e.g.,
g++via MinGW, GCC, or Clang). - Compile any
.cppfile using:g++ filename.cpp -o filename. - Run the executable:
./filename(Linux/macOS) orfilename.exe(Windows).
-
Clone the repository:
git clone https://github.com/H0NEYP0T-466/DSA.git
-
Navigate to the project directory:
cd DSA -
Ensure you have a C++ compiler installed:
- Linux/macOS: Install
g++via package manager - Windows: Install MinGW, MSYS2, or Visual Studio
- Online: Use platforms like Replit, CodeBlocks, or any online C++ compiler
- Linux/macOS: Install
-
Verify installation:
g++ --version
-
Compile a specific file (e.g.,
bfs_traversal.cpp):g++ bfs_traversal.cpp -o bfs_traversal
-
Run the program:
./bfs_traversal # Linux/macOS bfs_traversal.exe # Windows
-
Example workflow:
# Compile and run queue implementation g++ queues.cpp -o queues && ./queues # Compile and run binary search tree g++ binary_search_trees.cpp -o bst && ./bst # Compile and run graph traversal g++ dfs_traversal.cpp -o dfs && ./dfs
-
Explore the code, modify inputs, or use it as a reference for your learning!
This repository covers a wide range of DSA topics and LeetCode-style problems, including:
- Arrays:
- Basic array operations (
arrays.cpp) - Product of array except self (
product_ofarray_exceptself.cpp) - Largest rectangle in histogram (
largest_rectangle_histrogram,next_smallest_largest_element.cpp)
- Basic array operations (
- Linked Lists:
- Singly linked lists (
singly_linked_lists.cpp) - Doubly linked lists (
doubly_linked_lists.cpp) - Circular linked lists (
circular_linked_lists.cpp) - Doubly circular linked lists (
doubly_circular_linked_lists.cpp) - Cycle detection (
cycle_linkedlist.cpp) - Reverse linked list (
reverse_linkedLIst.cpp)
- Singly linked lists (
- Stacks & Queues:
- Stack implementation (
stack.cpp) - Queue implementation (
queues.cpp) - Queue using stacks (
queues_using_stacks.cpp) - Valid parenthesis checker (
valid_parenthesis.cpp)
- Stack implementation (
- Trees:
- Binary Tree (
binary_tree.cpp) - Binary Search Tree (
binary_search_trees.cpp) - AVL Trees (
avl_trees.cpp,avl _trees_rotations.cpp) - Validate BST (
validat_BST.cpp)
- Binary Tree (
- Graphs:
- Adjacency List (
adjacency_list.cpp) - Adjacency Matrix (
adjacency_matrix.cpp) - Breadth-First Search (
bfs_traversal.cpp) - Depth-First Search (
dfs_traversal.cpp) - Dijkstraโs Algorithm (
dijkstars_algo.cpp) - Bellman-Ford Algorithm (
bellman_ford_algo.cpp) - Primโs Algorithm (
prims_algo.cpp)
- Adjacency List (
- Heaps:
- Heap implementation (
heaps.cpp)
- Heap implementation (
- Hash Maps:
- Hash map implementation (
hash_map.cpp) - Two Sum problem (
two_sum.cpp)
- Hash map implementation (
- Miscellaneous:
- Longest substring without repeating characters (
longest_substring_without_repeating.cpp) - Next/previous smallest element (
next&prev_smallest element.cpp) - Pattern matching (
pattern.cpp) - Vectors (
vectors.cpp)
- Longest substring without repeating characters (
Weโre excited to keep growing this repository! Planned enhancements include:
- More LeetCode Problems: Add solutions to additional algorithmic challenges. ๐ฏ
- Optimizations: Improve time and space complexity for existing solutions. โก
- Competitive Programming: Include solutions tailored for platforms like Codeforces and AtCoder. ๐
- Documentation: Add detailed comments and explanations for complex algorithms. ๐
- Testing Framework: Introduce unit tests for each implementation. ๐งช
Contributions are welcome! Whether youโre fixing bugs, adding new algorithms, or improving documentation, your help is appreciated. To contribute:
- Fork the repository on GitHub.
- Clone your fork:
git clone https://github.com/your-username/DSA.git. - Create a new branch:
git checkout -b feature/your-feature-name. - Add your changes and commit:
git commit -m "Add your feature". - Push to your fork:
git push origin feature/your-feature-name. - Open a pull request with a clear description of your changes.
This project is licensed under the MIT License:
MIT License
Copyright (c) [YEAR] [AUTHOR_NAME]
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
- Open Source Community: For inspiring collaborative learning and development ๐
- Algorithm Enthusiasts: For sharing knowledge and best practices ๐
- Educational Platforms: LeetCode, HackerRank, and others for providing practice problems ๐ฏ
- C++ Community: For maintaining excellent documentation and resources ๐ป
- Contributors: Thank you to everyone who has contributed to this repository! ๐ค
๐ Start mastering DSA with C++ today! Letโs code, learn, and conquer those algorithms together! ๐ช