This repository contains implementations of various sorting algorithms in Python and C++.
-
Python:
- Open the desired sorting algorithm file (e.g.,
merge_sort.py
). - Copy the entire code.
- Paste it into your Python file or interactive Python environment.
- Call the sorting function by its name (the same name as the file and algorithm) with a list of elements to be sorted. (For now, the algorithm only works with numpy arrays. Lists coming soon.)
sorted_arr = merge_sort(arr)
- Customize the code or modify the input list (
arr
) to suit your needs.
- Open the desired sorting algorithm file (e.g.,
-
C++:
- Open the desired sorting algorithm file (e.g.,
merge_sort.cpp
). - Copy the entire code.
- Paste it into your C++ source file or create a new C++ file.
- Call the sorting function by its name (the same name as the file and algorithm) with an array or vector of elements to be sorted.
int sortedArr[] = mergeSort(arr);
- Customize the code or modify the input array (
arr
) to suit your needs. (Same here, only works with arrays, but soon I'll add the functionatlity with vectors.)
- Open the desired sorting algorithm file (e.g.,
-
merge_sort.py: Implementation of the Merge Sort algorithm in Python.
- For more information, see the Merge Sort Wikipedia article.
-
insertion_sort.py: Implementation of the Insertion Sort algorithm in Python.
- For more information, see the Insertion Sort Wikipedia article.
-
merge_sort.cpp: Implementation of the Merge Sort algorithm in C++.
- For more information, see the Merge Sort Wikipedia article.
-
insertion_sort.cpp: Implementation of the Insertion Sort algorithm in C++.
- For more information, see the Insertion Sort Wikipedia article.
Contributions are welcome! If you have suggestions, improvements, or other sorting algorithms you'd like to add, please submit a pull request.
This project is licensed under the MIT License.