samedi 7 mars 2015

I need help understanding a programming challenge


I am trying to do some homework and cannot wrap my head around a question. I have posted in the classes discussion board and emailed the professor but am not getting any help.


The question is: 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



virtual void Sort(int arr[], int size)= 0;


which, when overridden, will sort the array by calling the compare function to determine with the relative order of pairs of numbers (that is the phrase I don't get). 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 determine the number of comparisons performed.


I have an idea of how to code this but I just don't think that I am going about it the way the question is worded. I have written code to keep track of comparisons by incrementing a counter and outputting that number. The question is bugging me however. What does the author mean by saying "by calling the compare function to determine with the relative order of pairs of numbers "


Does anybody have any idea of what they mean? am I just over complicating an obvious question or is there some subtle challenge to this that I don't see. As I stated I do not need help coding the problem, just understanding the question.




Aucun commentaire:

Enregistrer un commentaire