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
- Excessively test each Sorting Algorithm with random arrays of different sizes from 10 to 1000000.
To get a local copy of this project up and running locally follow these simple example steps:
NOTE: How to check if Git is installed and what is its version
git -v
-
Please make sure you have git installed
-
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.
-
Navigate to the directory where you want to clone/run/save the application
cd your_selected_directory
-
Clone this repository
git clone https://github.com/GeorgiosIoannouCoder/sorting-algorithms.git
-
Navigate to the sorting-algorithms git repository
cd sorting-algorithms
-
Open your code editor.
code .
-
Run the .cpp file here.
The main code file can be found here.
The code of this project produces an output similiar to this:
The report of this project is located here. The tables and graph found inside the Report are loacted here.
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.
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!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
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.
Georgios Ioannou - @LinkedIn
Georgios Ioannou - @georgiosioannoucoder - Please contact me via the form in my portfolio.
Project Link: https://github.com/GeorgiosIoannouCoder/sorting-algorithms