This repository contains an implementation of several common sorting algorithms in C++. The purpose of this project is to provide a resource for anyone who wants to learn more about sorting algorithms and how they work.
The following algorithms are currently implemented:
- Bubble Sort ๐งผ
- Insertion Sort ๐ฉ
- Shell Sort ๐
- Selection Sort ๐๐
- Heap Sort ๐พ
- Merge Sort ๐ค
- Quick Sort โก
Each algorithm is implemented in its own C++ source file, which can be compiled and run as a standalone program or imported into another C++ project.
To compile and run any of the algorithms from the command line, simply navigate to the project directory and type:
g++ -std=c++11 <algorithm_name>.cpp -o <algorithm_name>
./<algorithm_name>
Replace <algorithm_name>
with the name of the C++ source file you want to compile and run.
Alternatively, you can include any of the source files in your own C++ project and use them as a library. For example:
#include "bubble_sort.h"
int main() {
int myArray[] = {4, 2, 7, 1, 3};
int arraySize = sizeof(myArray) / sizeof(int);
bubble_sort(myArray, arraySize);
for (int i = 0; i < arraySize; ++i) {
std::cout << myArray[i] << " ";
}
std::cout << std::endl;
return 0;
}
Contributions to this project are welcome! If you find a bug or want to add a new algorithm, please open an issue or submit a pull request.
This project was inspired by the sorting algorithms section of the Algorithms and Data Structures course on YouTube, taught by Dr.Ahmed Hamdy.
If you have any questions or comments about this project, please feel free to contact me at LinkedIn.
this ReadMe is written by ChatGPT :)