For this assignment you will have to create a hybrid sorting algorithm. A hybrid sorting algorithm is one that combines two different algorithms such as MergeSort + Bubble, or QuickSort + Selection. When creating a hybrid sorting algorithm, you are exploiting the benefits of both, while avoiding the worst cases.
Continuing the example of MergeSort + Bubble Sort, one approach could be letting MergeSort split the list into smaller chunks, then allowing Bubble Sort to sort those small chunks.
The reason for this, is that MergeSort may have an extremely high constant value, meaning that for low values of n
, bubble sort may actually be faster!
Need a refresher on this? See our notes on functions
This assignment will be hosted on Github Classroom.
- Register for the assignment on our Github Classroom using this link
- Be sure to select your name from the list to link your Github to the class roster!
- Clone the repository to your machine
- Open a terminal
- Navigate to your algorithms folder
- Go to the parent directory (
cd ..
) - Clone the repository to this location (
git clone <Link to your repository>
)- Be sure to use the link for your copy of the repository
- Getting things in order
- Open your new folder in VS Code
- Begin by creating a new file
source/Sorts/hybrid.cpp
.- Within this file, create the definition for your hybrid sorting algorithm:
void sort(int*, int) {}
- Within this file, create the definition for your hybrid sorting algorithm:
- Check your work by compiling and running your code (
make hybrid
) - Make sure the code compiled and ran, and that the unit tests for your function failed.
- Commit and push your code (
git add . && git commit -m "<message>" && git push
) - Check the online copy of your repository to make sure these changes were actually pushed
- Implement your algorithm (50 points)
- Select the algorithms you'd like to combine
- Decide when each algorithm should fire (maybe cases depending on the size of n)
- Write pseudocode for your algorithm
- Commit and push this pseudocode
- Implement your pseudocode in C++
- Remember that to use another sorting algorithm you must import it into it's own namespace.
- Pass all unit tests
- Commit and push your code
- Analyze your work (40 points)
- Provide your algorithms' Big-Oh, Omega, and Theta notation
- Explain and justify your decisions for when certain algorithms are called
- Provide theoretical and empirical reasoning for full credit
To submit this assignment, simply commit and push your work to your assignment repository. Your last submission before the deadline will be graded.
For this assignment, 50 points will be awarded for functionality, 40 for your analysis, and 10 for readability.