An open API service indexing awesome lists of open source software.

https://github.com/saifiimuhammad/data-structures-algorithms

This repository contains implementations of common algorithms and Leetcode problems in C++.
https://github.com/saifiimuhammad/data-structures-algorithms

algorithms cpp data-structures leetcode

Last synced: about 1 month ago
JSON representation

This repository contains implementations of common algorithms and Leetcode problems in C++.

Awesome Lists containing this project

README

          

# Data Structures and Algorithms

This repository contains implementations of common algorithms in **C++**. Below is a brief overview of each algorithm, its time complexity, and typical usage scenarios.

## Sorting Algorithms

1. **Bubble Sort**
- **Time Complexity:** O(n²)
- **Usage:** Simple but inefficient, used for small datasets or educational purposes.

2. **Selection Sort**
- **Time Complexity:** O(n²)
- **Usage:** Better than bubble sort for small datasets, useful for learning purposes.

3. **Quick Sort**
- **Time Complexity:** O(n log n) on average
- **Usage:** Efficient for large datasets; performance may degrade with bad pivot choices.

4. **Merge Sort**
- **Time Complexity:** O(n log n)
- **Usage:** Stable and consistent, ideal for large datasets where stability is required.

5. **Insertion Sort**
- **Time Complexity:** O(n²)
- **Usage:** Efficient for small datasets and nearly sorted data.

---

## Problem-Solving

1. **Two Sum Problem**
- **Description:** Find two numbers that add up to a target value.
- **Time Complexity:** O(n)
- **Usage:** Common problem in coding interviews.

2. **Counter Problem**
- **Description:** Count occurrences of elements in an array.
- **Time Complexity:** O(n)
- **Usage:** Useful for frequency counting.

3. **Remove Duplicates**
- **Description:** Remove duplicates from a sorted array.
- **Time Complexity:** O(n)
- **Usage:** Simplifies an array by removing duplicate values.

---

## Credits

Developed by [Muhammad Saif](https://github.com/saifiimuhammad).