Intro
Intro
The sorting algorithm is a widely used and highly applicable algorithm in everyday life. It can be
simply understood as the process of arranging the elements in a given array in a specific order.
However, this concept is still too vague. Therefore, the project is carried out with the goal of getting a
comprehensive overview of sorting algorithms, understanding their working principles, characteristics,
properties, advantages, and limitations, as well as the applications of some common algorithms.
Organizing data through the application of sorting algorithms is a fundamental technique that enables
efficient data retrieval and management. Despite the abundance of sorting algorithms available, each
individual method has its own distinct advantages and disadvantages.
In the context of this project, the team will undertake the implementation and comprehensive
exploration of 11 prominent sorting algorithms: Selection Sort, Insertion Sort, Bubble Sort, Shaker
Sort, Shell Sort, Heap Sort, Merge Sort, Quick Sort, Counting Sort, Radix Sort, and Flash Sort.
INFORMATION
Computer information
Central Processing Unit (CPU) Intel i7 - 12700H
OS Windows 10
Project organization and Programming notes
Project organization
All the source code files are saved in SOURCE directory:
+ Algorithms.cpp and Algorithms.h file : contain source code of 11 sorting algorithms including one .cpp
file and one .h file providing algorithm data for testing and evaluation.
+ DataGenerator.cpp and DataGenerator.h file : provide functions to generate array data with different
characteristics. These functions help to generate randomly ordered, ascending ordered, descending ordered
and nearly ordered arrays.
+ Helper.cpp and Helper.h file : contain functions that support the necessary requirements during the
project implementation process, including: implement sorting algorithms based on algorithm id, convert
data type of algorithm and input order, print out the result, check for valid input/file.
+ Experiment.cpp and Experiment.h file : contain five commands and functions writes the experimental
results to a file with information including data order, data size, sorting algorithm name, running time, and
number of comparisons.
+ In addition, besides the mentioned directories, there is also a main.cpp file that uses command line
parameters to execute the written program.
Programming notes
Some libraries used in this project are:
+ fstream library: provides classes and functions for file handling operations, such as opening,
reading, and writing to files.
+ string, cstring library: is used to perform string related operations.
+ iomanip library: provides functions and manipulators for formatting the output in a desired
manner.
+ cmath library: provides a wide range of mathematical functions and operations.
+ time.h library: provides functions and data types for working with time and date.
Usage guide:
+ Open a command prompt, use cd [direction to our source folder] to compile our source files
into an exe file, use : g++ .\*.cpp -o [exe file]
In this command:
It is used to compile C++ source files into an executable file with a specified
name.
g++: This is the command to invoke the g++ C++ compiler.
.\*.cpp: This is a file pattern that specifies all the C++ source files in the
current directory. The * character is a wildcard that matches any file name,
and .cpp specifies that only files with the .cpp extension will be compiled.
-o [exe file]: This is an option that specifies the name of the output
executable file. You need to replace [exe file] with the desired name for your
executable file.