This repository contains C++ and Python implementations of various sorting algorithms. Each algorithm is optimized for general use, well-documented, and includes time complexity analysis. Perfect for learning, interviews, and competitive programming! π
πΉ Bubble Sort β Repeatedly swaps adjacent elements (O(nΒ²)).
πΉ Selection Sort β Selects the smallest element iteratively (O(nΒ²)).
πΉ Insertion Sort β Builds a sorted array one element at a time (O(nΒ²)).
πΉ Merge Sort β A divide & conquer sorting algorithm (O(n log n)).
πΉ Quick Sort β Efficient sorting using pivot selection (O(n log n) avg).
πΉ Heap Sort β Sorts using a binary heap (O(n log n)).
πΉ Shell Sort β Improved Insertion Sort with gap sequences (O(n log n) avg).
πΉ Counting Sort β Works well for small-range integers (O(n + k)).
πΉ Radix Sort β Sorts numbers by digits (O(nk)).
πΉ Bucket Sort β Distributes elements into buckets (O(n) avg).
π Sorting-Algorithms
βββ π bubble_sort.cpp
βββ π selection_sort.cpp
βββ π insertion_sort.cpp
βββ π merge_sort.cpp
βββ π quick_sort.cpp
βββ π heap_sort.cpp
βββ π shell_sort.cpp
βββ π counting_sort.cpp
βββ π radix_sort.cpp
βββ π bucket_sort.cpp
βββ π bubble_sort.py
βββ π selection_sort.py
βββ π insertion_sort.py
βββ π merge_sort.py
βββ π quick_sort.py
βββ π heap_sort.py
βββ π shell_sort.py
βββ π counting_sort.py
βββ π radix_sort.py
βββ π bucket_sort.py
βββ π README.md  
| Algorithm | Best Case | Average Case | Worst Case | 
|---|---|---|---|
| Bubble Sort | O(n) | O(nΒ²) | O(nΒ²) | 
| Selection Sort | O(nΒ²) | O(nΒ²) | O(nΒ²) | 
| Insertion Sort | O(n) | O(nΒ²) | O(nΒ²) | 
| Merge Sort | O(n log n) | O(n log n) | O(n log n) | 
| Quick Sort | O(n log n) | O(n log n) | O(nΒ²) | 
| Heap Sort | O(n log n) | O(n log n) | O(n log n) | 
| Shell Sort | O(n log n) | O(n log n) | O(nΒ²) | 
| Counting Sort | O(n + k) | O(n + k) | O(n + k) | 
| Radix Sort | O(nk) | O(nk) | O(nk) | 
| Bucket Sort | O(n) | O(n) | O(nΒ²) | 
1οΈβ£ Clone this repository
git clone https://github.com/CyberMatic-AmAn/Sorting.git2οΈβ£ Compile and run any sorting program
For C++:
g++ merge_sort.cpp -o merge_sort
./merge_sortFor Python:
python merge_sort.pyFeel free to fork this repo, improve the code, and submit pull requests! π