https://github.com/mehedi-86/data_structure_and_algorithm
A comprehensive collection of Data Structures and Algorithms (DSA) in C++, covering key concepts for competitive programming, interviews, and academic learning with optimized implementations. π
https://github.com/mehedi-86/data_structure_and_algorithm
algorithm-analysis algorithm-design data-structures-and-algorithms dsa
Last synced: 3 months ago
JSON representation
A comprehensive collection of Data Structures and Algorithms (DSA) in C++, covering key concepts for competitive programming, interviews, and academic learning with optimized implementations. π
- Host: GitHub
- URL: https://github.com/mehedi-86/data_structure_and_algorithm
- Owner: Mehedi-86
- Created: 2025-03-16T20:09:25.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2025-03-16T20:22:40.000Z (3 months ago)
- Last Synced: 2025-03-16T21:26:36.447Z (3 months ago)
- Topics: algorithm-analysis, algorithm-design, data-structures-and-algorithms, dsa
- Language: C++
- Homepage:
- Size: 26.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
π Data Structure & Algorithm Repository
A comprehensive collection of fundamental and advanced algorithms implemented in C++.π Overview
This repository contains various Data Structure and Algorithm implementations in C++. It covers different problem-solving paradigms that are essential for competitive programming, coding interviews, and real-world applications. Each algorithm is implemented with an efficient approach and optimized for better performance.
π Folder Structure
DSA/
βββ ApproximationAlgo.cpp
βββ Array.cpp
βββ Backtracking.cpp
βββ BranchAndBound.cpp
βββ DivideAndConquer.cpp
βββ DynamicProgramming.cpp
βββ Graph.cpp
βββ Graph1.cpp
βββ Greedy.cpp
βββ HashingAndHashFunction.cpp
βββ HeapAndPrQueue.cpp
βββ LinkedList.cpp
βββ LinkedList1.cpp
βββ SortingAlgo.cpp
βββ Tree.cpp
βββ Tree1.cpp
βββ XorLinkedList.cppπ Implemented Algorithms
1οΈβ£ Sorting Algorithms
Sorting is a fundamental operation in computer science, used to arrange data in a specific order. Efficient sorting algorithms improve the performance of search operations and are widely used in databases, file management, and data processing.
-
Bubble Sort: A simple sorting algorithm with O(nΒ²) time complexity. -
Selection Sort: Finds the minimum element and swaps it into place. -
Insertion Sort: Builds the sorted list one element at a time. -
Merge Sort: A divide-and-conquer sorting technique with O(n log n) complexity. -
Quick Sort: Uses partitioning for sorting and has O(n log n) average complexity. -
Heap Sort: Uses a binary heap to sort elements efficiently.
2οΈβ£ Graph Algorithms
Graph algorithms are used to model relationships between objects. They are crucial in networking, AI, and route planning.
-
Breadth-First Search (BFS): Explores the shortest path in an unweighted graph. -
Depth-First Search (DFS): Explores as far as possible along a branch before backtracking. -
Dijkstra's Algorithm: Finds the shortest path from a single source. -
Kruskalβs Algorithm: Finds the Minimum Spanning Tree using a greedy approach. -
Primβs Algorithm: Constructs the Minimum Spanning Tree starting from any node. -
Bellman-Ford Algorithm: Computes shortest paths in graphs with negative weights.
3οΈβ£ Dynamic Programming
Dynamic Programming (DP) is a method for solving complex problems by breaking them down into simpler subproblems and storing their solutions to avoid recomputation.
-
Knapsack Problem: Maximizes value while staying within weight constraints. -
Longest Common Subsequence (LCS): Finds the longest sequence that appears in two strings. -
Longest Increasing Subsequence (LIS): Identifies the longest increasing order of numbers. -
Fibonacci using DP: Computes Fibonacci numbers efficiently. -
Matrix Chain Multiplication: Determines the optimal way to multiply matrices.
4οΈβ£ Greedy Algorithms
Greedy algorithms build solutions piece by piece, always choosing the next best option. They are useful when local optimization leads to global optimization.
-
Huffman Coding: A compression technique used in data encoding. -
Activity Selection: Selects the maximum number of activities that donβt overlap. -
Job Scheduling: Schedules jobs based on deadlines and profits. -
Fractional Knapsack: Similar to the Knapsack problem but allows fractional item selection.
5οΈβ£ Approximation Algorithms
Approximation algorithms provide near-optimal solutions to NP-hard problems where finding an exact solution is computationally expensive.
-
Travelling Salesman Problem (TSP): Finds an approximate shortest tour using the Minimum Spanning Tree (MST) heuristic. -
Vertex Cover Problem: Approximates the smallest vertex cover using a greedy approach. -
Knapsack Problem: Uses a greedy fractional approach to approximate the optimal solution. -
Scheduling Problems (Makespan Minimization): Uses the Longest Processing Time (LPT) heuristic for job scheduling. -
Maximum Cut Problem (Max-Cut): Approximates the maximum cut using randomized partitioning. -
Graph Coloring (Chromatic Number Approximation): Estimates the chromatic number using a greedy coloring approach.
π» Installation & Usage
To compile and run any C++ file, use the following command:
g++ filename.cpp -o output
./output
π Contribution
Contributions are welcome! If you find any issues or want to add new algorithms, feel free to submit a pull request. Follow these steps:
- Fork the repository
- Clone your fork:
git clone https://github.com/YourUsername/Data_Structure_And_Algorithm.git
- Create a new branch:
git checkout -b feature-name
- Make your changes and commit:
git commit -m "Added new feature"
- Push changes:
git push origin feature-name
- Submit a pull request
π License
This project is licensed under the MIT License.