C++ Data structures program

pallavisai
sampleMainP4.cpp

#include<iostream> #include<cstdlib> // used for random number generation #include<math.h> // used for ceil and floor functions in adaptive sort #include<ctime> // used for measuring time using namespace std; class sortElements{ protected: int numElements; //Number of elements of the array int short* elements; //dynamic array with the elements of type int short or int long(for experiment) public: sortElements(); // default constructor sortElements(int n); // non-default constructor ~sortElements(); // destructor void generateRandom(int seed, int lower, int upper); // will generate numElement set of elements randomly with the seed and range from lower to upper void displayElements(int short* arr); // display the given set int short* getElementsArray(); // return the entire array of elements int getnumElements(); // return the number of elements int short* shellSort(); // method used for shell sort bool isSorted(int short* array, int len); // helper method for adaptive sort int short* mergeArrays(int short* arr1, int short* arr2, int n1, int n2); // merge method for adaptive sort int short* adaptiveSort(int short* a, int length); // method for adaptive sort }; //main function int main() { // TODO: // get the number of elements and create a pointer object of class with the non default constructor // get the seed, lower and upper bounds for random number generation // TODO: // call the generateRandom method with s, l and u. cout << "Randomly generated elements: " << endl; // TODO: // call the displayElements method to display the randomly generated 'elements' // TODO: // call the shellSort method that would return the sortedElements. // this above call can be timed cout << "Shell sort sorted elements: " << endl; // TODO: // call the displayElements method to display the returned sortedElements from shellSort // TODO: // call the adaptiveSort method that would return the sortedElements. // this above call can be timed cout << "Adaptive sort sorted elements: " << endl; // TODO: // call the displayElements method to display the returned sortedElements from adaptiveSort return 0; }