Skip to content

mihu19/Sorting-Algorithms

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

101 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sorting-Algorithms

A C++ and Python project designed to implement, test, and benchmark various sorting algorithms.

This tool generates data arrays, sorts them using multiple techniques, and automatically logs performance metrics—such as execution time and memory usage into CSV files. The included Python tools can then be used to analyze and visualize the benchmark results.

Competition: “The Fastest Sorting Algorithm” - Hybrid Sort

Implemented Algorithms

The repository includes the following sorting algorithms:

  • Bubble Sort
  • Insertion Sort
  • Shell Sort
  • Merge Sort
  • Hybrid Sort (Radix Sort + Insertion Sort)

Project Structure

  • src/: Contains all C++ source code, including algorithm implementations, array generation, memory management, and CSV handling.
  • Tools/: Python scripts are used for analyzing, plotting, and visualizing the CSV benchmark data.
  • Results/: The output directory where the generated CSV benchmark files are saved.
  • Hybrid Sort/: Contains specific logic, data, or tests dedicated to the hybrid sorting approach.

Prerequisites

To compile and run this project:

  • C++ Compiler: Windows - g++, macOS - clang++
  • Windows PowerShell or standard command prompt.
  • (macOS) OpenMP library - required for parallel execution.
    brew install libomp
  • Python 3.x (Optional: only needed if you want to run the analysis scripts in the Tools/ folder).

Installation & Compilation

Option A: Using Visual Studio Code (No Git Required)

  1. Download the Code: Click the green Code button at the top of this repository and select Download ZIP. Extract the folder to your computer.

  2. Open the Project: Launch Visual Studio Code and open the extracted Sorting-Algorithms folder.

  3. Open the Terminal: In the top menu, click Terminal > New Terminal (or press Ctrl + `).

  4. Navigate to the Source Folder:

    cd src
  5. Compile:

    Windows:

     g++ main.cpp BubbleSort.cpp InsertionSort.cpp ShellSort.cpp MergeSort.cpp HybridSort.cpp ArrayGenerator.cpp Files.cpp Memory.cpp CSV.cpp -o sort -lpsapi -fopenmp -O3

    macOS

    clang++ main.cpp BubbleSort.cpp InsertionSort.cpp ShellSort.cpp MergeSort.cpp HybridSort.cpp ArrayGenerator.cpp Files.cpp Memory.cpp CSV.cpp -O3 -std=c++17 -Xpreprocessor -fopenmp -I$(brew --prefix libomp)/include -L$(brew --prefix libomp)/lib -lomp -o sort
  6. Run:

    Windows:

    .\sort.exe

    macOS:

    ./sort

Option B: Using CMD (Git Required)

  1. Clone the repository:

    git clone https://github.com/mihu19/Sorting-Algorithms.git
  2. Navigate to the src directory:

    cd Sorting-Algorithms/src
  3. Compile:

    Windows:

     g++ main.cpp BubbleSort.cpp InsertionSort.cpp ShellSort.cpp MergeSort.cpp HybridSort.cpp ArrayGenerator.cpp Files.cpp Memory.cpp CSV.cpp -o sort -lpsapi -fopenmp -O3

    macOS

    clang++ main.cpp BubbleSort.cpp InsertionSort.cpp ShellSort.cpp MergeSort.cpp HybridSort.cpp ArrayGenerator.cpp Files.cpp Memory.cpp CSV.cpp -O3 -std=c++17 -Xpreprocessor -fopenmp -I$(brew --prefix libomp)/include -L$(brew --prefix libomp)/lib -lomp -o sort
  4. Run:

    Windows:

    .\sort.exe

    macOS:

    ./sort

About

PBL Project - Sorting Algorithm -Algorithm Analysis and Implementation

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors