This repository contains implementations of common algorithms in C++. Below is a brief overview of each algorithm, its time complexity, and typical usage scenarios.
-
Bubble Sort
- Time Complexity: O(n²)
- Usage: Simple but inefficient, used for small datasets or educational purposes.
-
Selection Sort
- Time Complexity: O(n²)
- Usage: Better than bubble sort for small datasets, useful for learning purposes.
-
Quick Sort
- Time Complexity: O(n log n) on average
- Usage: Efficient for large datasets; performance may degrade with bad pivot choices.
-
Merge Sort
- Time Complexity: O(n log n)
- Usage: Stable and consistent, ideal for large datasets where stability is required.
-
Insertion Sort
- Time Complexity: O(n²)
- Usage: Efficient for small datasets and nearly sorted data.
-
Two Sum Problem
- Description: Find two numbers that add up to a target value.
- Time Complexity: O(n)
- Usage: Common problem in coding interviews.
-
Counter Problem
- Description: Count occurrences of elements in an array.
- Time Complexity: O(n)
- Usage: Useful for frequency counting.
-
Remove Duplicates
- Description: Remove duplicates from a sorted array.
- Time Complexity: O(n)
- Usage: Simplifies an array by removing duplicate values.
Developed by Muhammad Saif.