Question
C++ Design a class AbstractSort that can be used to analyze the number of comparisons performed by a sorting algorithm. The class should have a
C++
Design a class AbstractSort that can be used to analyze the number of comparisons performed by a sorting algorithm. The class should have a member function compare that is capable of comparing two array elements, and a means of keeping track of the number of comparisons performed. The class should be an abstract class with a pure virtual member function
void sort(int arr[ ], int size)
which, when overridden, will sort the array by calling the compare function to determine the relative order of pairs of numbers. Create a subclass of AbstractSort that uses a simple sorting algorithm to implement the sort function. The class should have a member function that can be called after the sorting is done to retrieve the number of comparisons performed.
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