Question
Sort Algorithms - Best/Worst Case This Replit project contains the three sort test programs and header files for the various sort algorithms presented in class.
Sort Algorithms - Best/Worst Case
This Replit project contains the three sort test programs and header files for the various sort algorithms presented in class. Of the three test programs (sorttest1.cpp, sorttest2.cpp, and sorttest3.cpp), only one should have the .cpp extension - this is the one that will be compiled and run. The other two should have an extension of .cpp.txt, causing them to be ignored by the compiler.
The analysis of the sort algorithms presented in class was based on the average case; the algorithm is presented with some seemingly random ordering of its values. As such, the Big-Oh analysis of each is an average case analysis.
Some sort algorithms may exhibit different run-time characteristics for a best-case or worst-case scenario. When this is the case, the scenario that presents such a case is typically when the arrangement of values in the array presented to the algorithm is already in correct sorted or reverse sorted order.
For each of the algorithms below, determine if the run-time growth of the algorithm is different from the Big-Oh runtime when presented with an array that is already in ascending order, and if it is different if presented with an array in descending order. Does the runtime for the sorted array exhibit a best-case scenario (Omega)? Does the runtime for the sorted array exhibit a worst-case scenario (Theta)? Or does it make no difference for the particular algorithm (Big-Oh applies to both best- and worst-case)?
Examine the code for each of these algorithms and make your determination based on an examination of the code. Explain how you arrived at your conclusion. Base your answers on the implementations included in this Replit project (note that online resources may discuss this issue but may be based on different implementations of the same algorithms). Be explicit citing line numbers in the code.
Prepare your responses in Markdown format in file README.md.
Give your analysis for the following algorithms:
Selection Sort (selection.h)
Insertion Sort (insertion.h)
Merge Sort, version 2 (merge2.h)
Quicksort (quick.h)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started