This project implements a comparison of run-times for insertion sort and merge sort. The merge sort implementation is based on code in Deitel and Deitel, sorting C++ standard library vectors of integers. In addition, I have also reimplemented a version of the project in Google's Go programming language that uses goroutines to simultaneously process multiple sorts.
/docs: Documents demonstrating the project/src: The source code for the projectmain.cpp: the project source code in C++insertionsort.csv: example insertion sort output from a prior runmergesort.csv: example merge sort output from a prior runDemonstration-and-Analysis-Cpp.ipynb: a Jupyter notebook that builds the project, automatically demonstrates its features, and analyzes the results
/go: The alternate version of the project written in Gomain.go: the project source code in Goinsertionsort.csv: example insertion sort output from a prior runmergesort.csv: example merge sort output from a prior runDemonstration-and-Analysis-Golang.ipynb: a Jupyter notebook that builds the project, automatically demonstrates its features, and analyzes the results
In a terminal, navigate to 532-project/src/cpp. Compile the project with the following command:
g++ -std="c++14" main.cpp -o main
Click Start → Programs → Visual Studio → Visual Studio Command Prompt. In the Visual Studio Command Prompt, navigate to 532-project\src\cpp. Compile the project with the following command:
cl main.cpp
In a terminal, navigate to 532-project/src/go. Compile the project with the following command:
go build -o gomain main.go
Open Windows PowerShell and navigate to 532-project\src\go. Compile the project with the following command:
go build -o gomain.exe main.go
I have provided Jupyter notebooks that demonstrate the operation of the project, for both the C++ and Golang versions. If your computer has the Python scientific computing stack installed (minimally numpy, pandas, matplotlib, and Jupyter), then the demonstrations may be run by entering jupyter notebook at the command line, navigating the the appropriate notebook, and clicking Kernel → Restart & Run All. (Note that this erases all output from previous runs and re-runs the project, which can take an hour or longer.) If you do not have the Python scientific libraries installed, I have exported sample runs of both in the C++ and Go versions html and pdf format in the docs folder.
A number of command line arguments are provided for various test runs. These work in both the C++ and Golang versions.
insertion-only: prevents merge sort from being runmerge-only: prevents insertion sort from being runequal-batches: instead of running each sort⌊512/p²⌋times, sorts are run in equal-sized batches.limit-n: only tests small arrays that can be tested quicklydemo-sorters: demonstrates that each sorting routine produces arrays that are correctly sorted in nondecreasing orderno-time: skips the main portion of the assignment, the obtaining of run-times