Skip to content

Analysis and Implementation of Compiler Time of Six Sorting Algorithms. 📶

License

Notifications You must be signed in to change notification settings

GeorgiosIoannouCoder/sorting-algorithms

Repository files navigation

Reporting and analyzing the compiler time of six Sorting Algorithms

Contributors Forks Stargazers Issues MIT License LinkedIn GitHub


Logo

In this programming assignment, I investigated the compiler time of six different Sorting Algorithms for different input sizes. The six Sorting Algorithms analyzed in this report are: Insertion Sort, Merge Sort, Heap Sort, Quick Sort, Randomized Quick Sort, and LSD Radix Sort. A code that was built from scratch was used to generate random arrays of different sizes from 10 to 1000000 an excessively test each Sorting Algorithm. The code is based on the pseudocodes found in the textbook: "Introduction to Algorithms, THIRD EDITION" by Cormen Leiserson,Rivest, and Stein and published by The MIT Press. The program was repeated twice and the average compiler time was reported.
Explore the docs »

Report Bug · Request Feature

Table of Contents
  1. About The Project
  2. Getting Started
  3. Code
  4. Output
  5. Report
  6. Analysis
  7. Contributing
  8. License
  9. Contact

About The Project

Logo

Sorting Algorithms

Sorting Algorithms

Back to top

Key Feature

  1. Excessively test each Sorting Algorithm with random arrays of different sizes from 10 to 1000000.

Back to top

Built With

C++ VisualStudio Excel Git

Back to top

Getting Started

To get a local copy of this project up and running locally follow these simple example steps:

Prerequisites

NOTE: How to check if Git is installed and what is its version

  git -v
  1. Please make sure you have git installed

  2. Please make sure you have Visual Studio or Visual Studio Code with the C/C++ extension installed. You can download Visual Studio here. You can download Visual Studio Code here.

NOTE: You can use whatever code editor that you want. This project was created and tested with Visual Studio.

Installation

SetUp

  1. Navigate to the directory where you want to clone/run/save the application

    cd your_selected_directory
  2. Clone this repository

    git clone https://github.com/GeorgiosIoannouCoder/sorting-algorithms.git
  3. Navigate to the sorting-algorithms git repository

    cd sorting-algorithms
  4. Open your code editor.

    code .
  5. Run the .cpp file here.

Back to top

Code

The main code file can be found here.

Back to top

Output

The code of this project produces an output similiar to this:

Logo

Back to top

Report

The report of this project is located here. The tables and graph found inside the Report are loacted here.

Back to top

Analysis

As I stated in my hypothesis in the Report and by studying Table 3 and Figure 1, the slowest Sorting Algorithm is Insertion Sort and the fastest Sorting Algorithm is LSD Radix Sort among these six Algorithms. I was also correct that Quick Sort beats Heap Sort which beats Merge Sort. However, Randomized Quick Sort (picking random pivot) is not faster than Quick Sort (picking the last element as the pivot). In fact, Randomized Quick Sort is sometimes slower than Heap Sort such as in the case when the input size is N=1000000. However, as the table shows, Insertion Sort even though it is a quadratic Sorting Algorithm it is faster than Merge Sort, Randomized Quick Sort, and LSD Radix Sort for small array sizes and nearly sorted arrays. Insertion Sort starts to be slow when the input size N gets larger.

Table 1

Table 2

Table 3

Time versus input

Back to top

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Back to top

License

Distributed under the MIT License. See LICENSE for more information.

MIT License

Copyright (c) 2021 Georgios Ioannou

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Back to top

Contact

Georgios Ioannou - @LinkedIn

Georgios Ioannou - @georgiosioannoucoder - Please contact me via the form in my portfolio.

Project Link: https://github.com/GeorgiosIoannouCoder/sorting-algorithms

Back to top