Skip to content

dipak140/Sorting_Algorithms

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 

Repository files navigation

🧠 Sorting Algorithms Collection

This repository aims to combine all (eventually) sorting algorithms into one piece of code as a quick refresher for beginners and experts. It also measures the time taken by each sorting algorithm function.

📜 Implemented Sorting Algorithms:

1. 🟨 Selection Sort

Time Complexity:

  • Average: O(n²)
  • Worst: O(n²)

Description:
Loops through the list while constantly moving the smallest value in the unsorted part to the end of the sorted part.

Watch Video


2. 🟩 Insertion Sort

Time Complexity:

  • Average: O(n²)
  • Worst: O(n²)

Description:
Loops through the list and moves each element value down into the correct location of the currently sorted part.

Watch Video


3. 🟥 Bubble Sort

Time Complexity:

  • Average: O(n²)
  • Worst: O(n²)

Description:
Loops through the list and repeatedly compares adjacent elements and swaps them if needed.

Watch Video


4. 🟦 Quick Sort

Time Complexity:

  • Average: O(n log n)
  • Worst: O(n²)

Description:
Paritions array into two based off of a pivot index. One holds values less than pivot, the other holds values higher than pivot. Then recursively sorts the two arrays.

Watch Video


🔧 How to Build & Run

🐧 Linux / 🍎 macOS

Use the following command in your terminal:

g++ sortOfAllSort.cpp -o sortOfAllSort && ./sortOfAllSort

💡 Note: Make sure g++ is installed.

  • On Ubuntu/Debian: bash sudo apt install g++

  • On macOS (with Homebrew): bash brew install gcc



🪟 Windows

Option 1: Using Visual Studio

  • Open sortOfAllSort.cpp in Visual Studio.

  • Use the build and run buttons to compile and execute.


Option 2: Using g++ (MinGW or WSL)

  • If you have g++ installed (e.g., via MinGW or Windows Subsystem for Linux), run the following in Command Prompt, PowerShell, or WSL:
g++ sortOfAllSort.cpp -o sortOfAllSort && sortOfAllSort

💡 Tip: Ensure g++ is in your system's PATH. You can check with bash g++ --version in your terminal.

About

This repository aims to combine all(eventually) sorting algorithms into one piece of code as a quick refresh for beginners and experts. It also measure the time taken by each sorting algorithm function.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages