C++ , Polymorphism, Compare two sorting algorithms, quick Sort & Max Sort with Virtual functions

preview_player
Показать описание
Rio Hondo Colege
CIT 126 C++ Programming class
Professor Liu is going to teach you a polymorphism project abstractSort class to analyze two sorting algorithms. Max Sort and Quick Sort are two derived classes which inherits the base class abstractSort class.
This abstractSort eclass has one private variable – ComparisionCount, one protected function, “compare “ used to compare two integers.
This class has a virtual function sort. Which will allow the derived classes to implement the sort function.
Two derived classes, MaxSort and QuickSort inherits the abstractSort class and the sort function. However each class will implement the virtual function sort with different approaches
I am going to use the different classes and object in my main program.
The code for the Max sort is on the screen right now ,
In this class Max sort implements the virtual sort function.
I will use a max sort to sort an array of 10 elements.
Let us see how many times the program need to perform comparison to sort the array.
36 times
Let me use another sorting algorithm

the code for the quick Sort is on the screen right now.
Quick sort use different implementation to the sort function . I will use a quick sort to sort an array of 10 elements.
Let us see how many times the QuickSort program need to perform comparison to sort an array of 10 elements
Array of 10 elements for quicksort only needs 23 times.
From the result, the quick sort is more effective than the max sort because it takes less comparisons time to sort an array.
The program can serve as an utility project to compare the efficiency of different sorting algorithm. I hope this is a helpful project and you can use it later
Рекомендации по теме
welcome to shbcf.ru