int main() { //待排数据输入方式: /*int N = 0; cout << "排序数据个数:\n"; cin >> N; int* A = new int[N]; cout << "请输入待排序的数据:\n"; for (int i = 0; i < N; i++) { cin >> A[i]; }*/ //数据直接给定 int B[N] = { 1, 6, 3, 5, 2, 4 }; int C[13] = { 54, 35, 48, 36, 27, 12, 44, 44, 8, 14, 26, 17, 2 }; int* A = C; //从文件中读取,大量数据,计算时间复杂度 printResult("待排原始数据:", C, N); BubbleSort bubble; bubble.bubbleSort(A,N); printResult("bubbleSort", A, N); SelectionSort select; select.selectionSort(A, N); printResult("selectSort", A, N); InsertionSort insert; insert.insertionSort(A, N); printResult("InsetSort", A, N); MergeSort merge; merge.mergeSort(A, N); printResult("MergeSort", A, N); QuickSort qucik; qucik.quickSort(A, N); printResult("QucikSort",A,N); QuickSort2 qucik2; qucik2.quickSort(A, N); printResult("QucikSort2", A, N); HeapSort heap; heap.heapSort(A, N); printResult("heapSort", A, N); HeapSort2 heap2; heap2.heapSort(A, N); printResult("heapSort2", A, N); ShellSort shell; shell.shellSort(A,N); printResult("shellSort", A, N); return 0; }
int main(void){ SelectionSort sort; sort.SetValue(RandomData()); sort.OutputData(); sort.Sort(); sort.OutputData(); cout << "\nResult End!\n"; system("pause"); return 0; }
int main() { SelectionSort sorter; sorter.readList(); sorter.sort(); cout << "Output:\n"; sorter.printArray(); return 0; }
int main() { //get input for asceding or descending int direction = 0; while (direction != 1 && direction != 2){ cout << "Press 1 for ascending -- Press 2 for descending. " << endl; cin >> direction; } //init SelectionSort class + begin tests SelectionSort select; //RECURSIVE selection sort populate(); cout << "Selection Sort [recursive]: " << endl; //small array + vec printData(arrayS, small); select.recursiveSort(direction, arrayS, small, 0); printData(arrayS, small); printData(vecS, small); select.recursiveSort(direction, vecS, small, 0); printData(vecS, small); //large array + vec select.recursiveSort(direction, arrayL, large, 0); select.recursiveSort(direction, vecL, large, 0); //ITERATIVE selection sort populate(); cout << "Selection Sort [iterative]: " << endl; //small array + vec printData(arrayS, small); select.iterativeSort(direction, arrayS, small); printData(arrayS, small); printData(vecS, small); select.iterativeSort(direction, vecS, small); printData(vecS, small); //large array + vec select.iterativeSort(direction, arrayL, large); select.iterativeSort(direction, vecL, large); return 0; }
int main(int argc,char* argv[]) { /* check for the correct number of inputs */ if(argc != 3) { cout << "Error: Wrong number of arguments\n"; cout << "Usage: ./SelectionSort datatype input_file\n"; return 1; } /* take datatype string into a string object */ string dType = argv[1]; // if datatype is int if(dType == "int") { /* declare the object of its type */ SelectionSort<int> is; /* load the input array */ is.load_input(argv[2]); is.print(); // print the array cout << endl; is.sort_inc(); // sort the array in increasing order cout << "increasing order :"; is.print(); // print the array cout << endl; is.sort_dec(); // sort the array in decreasing order cout << "decreasing order :"; is.print(); // print the array cout << endl; } // if datatype is string else if(dType == "string") { /* declare the object of its type */ SelectionSort<string> is; /* load the input array */ is.load_input(argv[2]); is.print(); // print the array cout << endl; is.sort_inc(); // sort the array in increasing order cout << "increasing order :"; is.print(); // print the array cout << endl; cout << "decreasing order :"; is.sort_dec(); // sort the array in decreasing order is.print(); // print the array cout << endl; } // if datatype is char else if(dType == "char") { /* declare the object of its type */ SelectionSort<char> is; /* load the input array */ is.load_input(argv[2]); is.print(); // print the array cout << endl; is.sort_inc(); // sort the array in increasing order cout << "increasing order :"; is.print(); // print the array cout << endl; is.sort_dec(); // sort the array in decreasing order cout << "decreasing order :"; is.print(); // print the array cout << endl; } // if datatype is float else if(dType == "float") { /* declare the object of its type */ SelectionSort<float> is; /* load the input array */ is.load_input(argv[2]); is.print(); // print the array cout << endl; is.sort_inc(); // sort the array in increasing order cout << "increasing order :"; is.print(); // print the array cout << endl; is.sort_dec(); // sort the array in decreasing order cout << "decreasing order :"; is.print(); // print the array cout << endl; } else { cout << "Unknown datatype\n"; } return 0; }
int main() { const int dataSizeSmall = 20; //the size of the small data set const int loSmall = 100; //the lower bound for random number generation of the small data set const int hiSmall = 300; //the higher bound for random number generation of the small data set int arrSmall_1[dataSizeSmall]; //a C-style array with dataSize elements, arrSmall_1 dataGenerator(arrSmall_1, dataSizeSmall, loSmall, hiSmall); //arr_1 was generated with random number between lo and hi int arrSmall_2[dataSizeSmall]; //another C-style array with dataSize elements, arrSmall_2 copy(arrSmall_1, arrSmall_1 + dataSizeSmall, arrSmall_2); //helper function: std::copy, copy arrSmall_2 from arrSmall_1 vector<int> vecSmall_1(arrSmall_1, arrSmall_1 + dataSizeSmall); //define a STL vector, copy vecSmall_1 from arrSmall_1 vector<int> vecSmall_2 = vecSmall_1; //copy vecSmall_2 from vecSmall_1 cout << "---------------- Now test selection sorting with " << dataSizeSmall << " elements ----------------" << endl; cout << endl; //display the arr_1, arr_2, and vec_1, vec_2 cout << "Before the selection sort, arrSmall_1: " << endl; printData(arrSmall_1, dataSizeSmall); cout << "Before the selection sort, arrSmall_2: " << endl; printData(arrSmall_2, dataSizeSmall); cout << "Before the selection sort, vecSmall_1: " << endl; printData(vecSmall_1, dataSizeSmall); cout << "Before the selection sort, vecSmall_2: " << endl; printData(vecSmall_2, dataSizeSmall); SelectionSort ssSmall; //an instance of class SelectionSort ssSmall.recursiveSort(arrSmall_1, dataSizeSmall); //sort a C-style arrays with recursive method cout << "After the recursive selection sort, arrSmall_1: " << endl; printData(arrSmall_1, dataSizeSmall); ssSmall.iterativeSort(arrSmall_2, dataSizeSmall);//sort a C-style arrays with iterative method cout << "After the iterative selection sort, arrSmall_2: " << endl; printData(arrSmall_2, dataSizeSmall); ssSmall.recursiveSort(vecSmall_1); //sort a STL vector with recursive method cout << "After the recursive selection sort, vecSmall_1: " << endl; printData(vecSmall_1, dataSizeSmall); ssSmall.iterativeSort(vecSmall_2); //sort a STL vector with iterative method cout << "After the iterative selection sort, vecSmall_2: " << endl; printData(vecSmall_2, dataSizeSmall); cout << endl; ///////////////////////////////////////////////////////////////////////////////////////////////////// // Analyze performance of selection algorithms using large arrays and large vectors. const int dataSizeLarge = 8000; //the size of the large data set const int loLarge = 0; //the lower bound for random number generation const int hiLarge = 10000; //the higher bound for random number generation int arrLarge_1[dataSizeLarge]; //a C-style array with dataSizeLarge elements, arr_1 dataGenerator(arrLarge_1, dataSizeLarge, loLarge, hiLarge); //arr_1 was generated with random number between lo and hi int arrLarge_2[dataSizeLarge]; //another C-style array with dataSizeLarge elements, arr_2 copy(arrLarge_1, arrLarge_1 + dataSizeLarge, arrLarge_2); //helper function: std::copy, copy large arr_2 from large arr_1 vector<int> vecLarge_1(arrLarge_1, arrLarge_1 + dataSizeLarge); //define a STL vector, copy vec_1 from arr_1 vector<int> vecLarge_2(vecLarge_1); //copy large vec_2 from large vec_1 cout << "---------------- Now test selection sorting with " << dataSizeLarge << " elements ----------------" << endl; cout << endl; SelectionSort ssLarge; //an instance of class SelectionSort TimeStamp ts; //an instance for class TimeStamp cout << "For recursively sorting large C-style array with " << dataSizeLarge << " elements: " << endl; cout << "Start time: " << ts.GetTime() << endl; //print timestamp ssLarge.recursiveSort(arrLarge_1, dataSizeLarge); //sort a C-style arrays with recursive method cout << "Ending time: " << ts.GetTime() << endl; //print timestamp cout << endl; cout << "For iteratively sorting large C-style array with " << dataSizeLarge << " elements: " << endl; cout << "Start time: " << ts.GetTime() << endl; //print timestamp ssLarge.iterativeSort(arrLarge_2, dataSizeLarge);//sort a C-style arrays with iterative method cout << "Ending time: " << ts.GetTime() << endl; //print timestamp cout << endl; cout << "For recursively sorting large STL vector with " << dataSizeLarge << " elements: " << endl; cout << "Start time: " << ts.GetTime() << endl; //print timestamp ssLarge.recursiveSort(vecLarge_1); //sort a STL vector with recursive method cout << "Ending time: " << ts.GetTime() << endl; //print timestamp cout << endl; cout << "For iteratively sorting large STL vector with " << dataSizeLarge << " elements: " << endl; cout << "Start time: " << ts.GetTime() << endl; //print timestamp ssLarge.iterativeSort(vecLarge_2); //sort a STL vector with iterative method cout << "Ending time: " << ts.GetTime() << endl; //print timestamp cout << endl; }
int main() { /********************************************** *Create two arrays where each will hold 200 integer values. *************************************************/ const int FILE_SIZE = 200; int randomData1[FILE_SIZE] = { 0 }; int randomData2[FILE_SIZE] = { 0 }; int value = 869; LoadArray loadArray1; BubbleSort bubbleSort1; SelectionSort selectSort; BinarySearch binarySearch; LinearSearch linearSearch; DisplayReport displayReport; int bubbleExchangeCount = 0; int selectionExchangeCount = 0; int linearSearchCount = 0; int binarySearchCount = 0; int arraySize = 0; /********************************************* * Bring in and load random.txt file into two arrays * Each array will hold the contents of a file(random.txt) * of 200 integer values. *************************************************/ loadArray1.loadTwoArray(randomData1, randomData2, FILE_SIZE); //load from file /****************************************************** *Using the two arrays, *call a function: * --that uses the bubble sort algorithm to sort one of the arrays in ascending order. * --& counts the number of exchanges it makes. *******************************************************************/ bubbleExchangeCount = bubbleSort1.bubbleSortArray(randomData1, FILE_SIZE); /******************************************************** Call a function: *--that uses the selection sort algorithm to sort the other array. *--& counts the number of exchanges it makes. *******************************************************/ selectionExchangeCount = selectSort.selectSortArray(randomData2, FILE_SIZE); /************************************************** *Display number of Exchanges for: --Bubble Sort --Selection Sort ***********************************************************/ displayReport.displayRepHeader(); displayReport.displaySortRep(bubbleExchangeCount, selectionExchangeCount); /*********************************************************** *Call a function : --that uses the linear search algorithm to locate the value 869. --& keep a count of the number of comparisons it makes until it finds the value. *Call a function : --that uses the binary search algorithm to locate the same value. * --& keep count of the numbers of comparisons it makes. ******************************************************************/ linearSearchCount = linearSearch.linearSearchArray(randomData1, FILE_SIZE, value); binarySearchCount = binarySearch.binarySearchArray(randomData2, FILE_SIZE, value); /************************************************** *Display number of Exchanges for: --Linear Search --Binary Search ***********************************************************/ displayReport.displaySearchRep(linearSearchCount, binarySearchCount); return 0; }
void main() { string timeString; TimeStamp ts; const int size = 20; //small size const int size1 = 2000; //large size int arr1[size]; //small array int arr2[size1]; //large array int arr1Copy[size];//copy of small array int arr2Copy[size1]; //copy of large array vector < int > numbers1(size); //small vector vector < int > numbers2(size1); //large vector vector < int > numbers1Copy(size); //copy of small vector vector < int > numbers2Copy(size1); //copy of large vector int choice = 0; char ans; cout << "---------------------------------------------------" << endl; cout << "\n WELCOME TO SELECTION SORT" << endl; cout << "---------------------------------------------------" << endl; SelectionSort sort; do { cout <<"\n HOW WOULD YOU LIKE TO SORT ?" <<endl<< "\n 1.ASCENDING" << endl << "\n 2.DESCENDING" << endl << "\n ENTER YOU CHOICE : "; cin.clear(); cin.sync(); cin >> choice; createArray(arr1, size); //call helper function to put random data in small array switch (choice) { case 1: for (int i = 0; i < size; i++) //making copy of small array { arr1Copy[i] = arr1[i]; } createArray(arr2, size1); //call helper function to put random data in large array for (int i = 0; i < size1; i++) //making copy of large array { arr2Copy[i] = arr2[i]; } createArray(numbers1, size); //call helper fundtion to create a small vector numbers1Copy = numbers1; //making copy of small vector createArray(numbers2, size1); //call helper fundtion to create a large vector numbers2Copy = numbers2; //making copy of large vector cout << "\n SORTING SMALL ARRAYS IN ASCENDING ORDER" << endl; cout << "--------------------------------------------------------------------------------------------------------------------------------------------------" << endl; cout << " ARRAY BEFORE SORTING" << endl; printArray(arr1, size); //printing array before sorting timeString = ts.GetTime(); cout << "\n "<< timeString << endl; sort.sortAscendingRecurse(arr1, size); //call the sorting function to sort the array recursively cout << "\n SORTING ARRAY USING RECURSION" << endl; cout << " ---------------------------" << endl; printArray(arr1, size); //printing the array after sorting timeString = ts.GetTime(); cout << "\n " << timeString << endl; sort.selectionSortAscending(arr1Copy, size); //call the sorting function to sort the copy of original array using iteration cout << "\n SORTING ARRAY USING ITERATION" << endl; cout << " ---------------------------" << endl; printArray(arr1Copy, size); //printing the copy of original array after sorting timeString = ts.GetTime(); cout << "\n " << timeString << endl; cout << "\n SORTING SMALL VECTORS IN ASCENDING ORDER" << endl; cout << "--------------------------------------------------------------------------------------------------------------------------------------------------" << endl; cout << "\n VECTOR BEFORE SORTING" << endl; printArray(numbers1, size); //printing the vector before sorting timeString = ts.GetTime(); cout << "\n " << timeString << endl; sort.sortAscendingRecurse(numbers1, size); //call the sorting function to sort the vector recursively cout << "\n SORTING VECTOR USING RECURSION" << endl; cout << " ---------------------------" << endl; printArray(numbers1, size); //printing the vector after sorting timeString = ts.GetTime(); cout << "\n " << timeString << endl; sort.selectionSortAscending(numbers1Copy, size); //call the sorting function to sort the copy of original vector using iteration cout << "\n SORTING VECTOR USING ITERATION" << endl; cout << " ---------------------------" << endl; printArray(numbers1Copy, size); //printing the copy of original vector after sorting timeString = ts.GetTime(); cout << "\n " << timeString << endl; cout << "\n TIME TAKEN FOR SORTING LARGE ARRAYS IN ASCENDING ORDER" << endl; cout << "--------------------------------------------------------------------------------------------------------------------------------------------------" << endl; //cout << " ARRAY BEFORE SORTING" << endl; //printArray(arr2, size1); //printing the large array before sorting //cout << timeString << endl; cout << "\n TIME BEFORE SORTING LARGE ARRAY USING RECURSION--" ; timeString = ts.GetTime(); cout << timeString << endl; sort.sortAscendingRecurse(arr2, size1); //call the sorting function to sort the large array recursively cout << "\n TIME AFTER SORTING LARGE ARRAY USING RECURSION--"; timeString = ts.GetTime(); cout << timeString << endl; //printArray(arr2, size1); //printing the large array after sorting cout << "\n TIME BEFORE SORTING LARGE ARRAY USING ITERATION--" ; timeString = ts.GetTime(); cout << timeString << endl; sort.selectionSortAscending(arr2Copy, size1); //call the sorting function to sort the copy of original large array using iteration cout << "\n TIME AFTER SORTING LARGE ARRAY USING ITERATION--" ; timeString = ts.GetTime(); cout << timeString << endl; //printArray(arr2Copy, size1); //printing the copy of original large array after sorting cout << "\n TIME FOR SORTING LARGE VECTORS IN ASCENDING ORDER" << endl; cout << "--------------------------------------------------------------------------------------------------------------------------------------------------" << endl; cout << "\n TIME BEFORE SORTING THE VECTOR USING RECURSION--"; //printArray(numbers2, size1); //printing the large vector before sorting //cout << "\n SORTING VECTOR USING RECURSION" << endl; timeString = ts.GetTime(); cout << timeString << endl; sort.sortAscendingRecurse(numbers2, size1); //call the sorting function to sort the large vector recursively cout << "\n TIME AFTER SORTING THE VECTOR USING RECURSION--"; timeString = ts.GetTime(); cout << timeString << endl; //printArray(numbers2, size1); //printing the large vector after sorting //cout << "\n SORTING VECTOR USING ITERATION" << endl; //cout << " ---------------------------" << endl; cout << "\n TIME BEFORE SORTING THE VECTOR USING ITERATION--"; timeString = ts.GetTime(); cout << timeString << endl; sort.selectionSortAscending(numbers2Copy, size1); //call the sorting function to sort the large vector using iteration //printArray(numbers2Copy, size1); //printing the large vector after sorting cout << "\n TIME AFTER SORTING THE VECTOR USING ITERATION--"; timeString = ts.GetTime(); cout << timeString << endl; break; case 2: ////same logic as above for descending order for (int i = 0; i < size; i++) //making copy of small array { arr1Copy[i] = arr1[i]; } createArray(arr2, size1); //call helper function to put random data in large array for (int i = 0; i < size1; i++) //making copy of large array { arr2Copy[i] = arr2[i]; } createArray(numbers1, size); //call helper fundtion to create a small vector numbers1Copy = numbers1; //making copy of small vector createArray(numbers2, size1); //call helper fundtion to create a large vector numbers2Copy = numbers2; //making copy of large vector cout << "\n SORTING SMALL ARRAYS IN DESCENDING ORDER" << endl; cout << "--------------------------------------------------------------------------------------------------------------------------------------------------" << endl; cout << " ARRAY BEFORE SORTING" << endl; printArray(arr1, size); //print function to print array before sortin timeString = ts.GetTime(); //use of timestamp library to prin the time bfore sort cout << "\n" << timeString << endl; sort.sortDescendingRecurse(arr1, size); //using sort function to sort recursively in descending order cout << "\n SORTING ARRAY USING RECURSION" << endl; cout << " ---------------------------" << endl; printArray(arr1, size); //printing the array after sorting timeString = ts.GetTime(); //use of timestamp library to prin the time after sort cout << "\n" << timeString << endl; sort.selectionSortDescending(arr1Copy, size); //use of sort function to sort copy of original array using iteration cout << "\n SORTING ARRAY USING ITERATION" << endl; cout << " ---------------------------" << endl; printArray(arr1Copy, size); //printing after sorting timeString = ts.GetTime(); cout << "\n" << timeString << endl; cout << "\n SORTING SMALL VECTORS" << endl; cout << "--------------------------------------------------------------------------------------------------------------------------------------------------" << endl; cout << "\n BEFORE VECTOR SORTING" << endl; printArray(numbers1, size); //printing vector before sort timeString = ts.GetTime(); cout << "\n" << timeString << endl; sort.sortDescendingRecurse(numbers1, size); //use sort function to sort in descending order recursively cout << "\n SORTING VECTOR USING RECURSION" << endl; cout << " ---------------------------" << endl; printArray(numbers1, size); //printing the vector after sorting timeString = ts.GetTime(); cout << "\n" << timeString << endl; sort.selectionSortDescending(numbers1Copy, size); //use sort function to sort the copy of original vector using iteration cout << "\n SORTING VECTOR USING ITERATION" << endl; cout << " ---------------------------" << endl; printArray(numbers1Copy, size); //printing the vector after sorting timeString = ts.GetTime(); cout << "\n" << timeString << endl; cout << "\n TIME TAKEN FOR SORTING LARGE ARRAYS IN DESCENDING ORDER" << endl; cout << "--------------------------------------------------------------------------------------------------------------------------------------------------" << endl; //cout << " BEFORE SORTING" << endl; //cout << timeString << endl; cout << "\n TIME BEFORE SORTING LARGE ARRAY USING RECURSION--"; timeString = ts.GetTime(); cout << timeString << endl; sort.sortDescendingRecurse(arr2, size1); //printArray(arr2, size1); cout << "\n TIME AFTER SORTING LARGE ARRAY USING RECURSION--"; timeString = ts.GetTime(); cout << timeString << endl; cout << "\n TIME BEFORE SORTING LARGE ARRAY USING ITERATION--"; timeString = ts.GetTime(); cout << timeString << endl; sort.selectionSortDescending(arr2Copy, size1); //printArray(arr2Copy, size1); cout << "\n TIME AFTER SORTING LARGE ARRAY USING ITERATION--"; timeString = ts.GetTime(); cout << timeString << endl; cout << "\n TIME TAKEN FOR SORTING LARGE VECTORS IN DESCENDING ORDER" << endl; cout << "--------------------------------------------------------------------------------------------------------------------------------------------------" << endl; //cout << " BEFORE SORTING" << endl; //printArray(numbers2, size1); cout << "\n TIME BEFORE SORTING LARGE VECTOR USING RECURSION--"; timeString = ts.GetTime(); cout << timeString << endl; sort.sortDescendingRecurse(numbers2, size1); //printArray(numbers2, size1); cout << "\n TIME AFTER SORTING LARGE VECTOR USING RECURSION--" ; timeString = ts.GetTime(); cout << timeString << endl; cout << "\n TIME BEFORE SORTING LARGE VECTOR USING ITERATION--"; timeString = ts.GetTime(); cout << timeString << endl; sort.selectionSortDescending(numbers2Copy, size1); //printArray(numbers2Copy, size1); cout << "\n TIME AFTER SORTING LARGE VECTOR USING ITERATION--" ; timeString = ts.GetTime(); cout << timeString << endl; break; default: cout << " SORRY !!!! INVALID NUMBER ENTERED\n" << endl; break; } cout << "\n PRESS 'Y' or 'y' TO CONTINUE or PRESS ANY KEY TO EXIT : "; cin.clear(); cin.sync(); cin >> ans; choice = 0; } while ((ans == 'Y') || (ans == 'y')); }
void TestSortingAlgos() { try { BubbleSort testBObj; int arrB[ARRAY_SIZE] = { 15,3,12,10,1,9,6,11,5,4 }; testBObj.LoadData(arrB, ARRAY_SIZE); testBObj.Print(); testBObj.Sort(); cout << "Bubble Sort Output:"; testBObj.Print(); SelectionSort testSObj; int arrS[ARRAY_SIZE] = { 15,3,12,10,1,9,6,11,5,4 }; testSObj.LoadData(arrS, ARRAY_SIZE); testSObj.Print(); testSObj.Sort(); cout << "Selection Sort Output:"; testSObj.Print(); InsertionSort testIObj; int arrI[ARRAY_SIZE] = { 15,3,12,10,1,9,6,11,5,4 }; testIObj.LoadData(arrI, ARRAY_SIZE); testIObj.Print(); testIObj.Sort(); cout << "Insertion Sort Output:"; testIObj.Print(); MergeSort testMObj; int arrM[ARRAY_SIZE] = { 15,3,12,10,1,9,6,11,5,4 }; testMObj.LoadData(arrM, ARRAY_SIZE); testMObj.Print(); testMObj.Sort(); cout << "Insertion Sort Output:"; testMObj.Print(); QuickSort testQObj; int arrQ[] = { 15,3,12,10,1,9,6,11,5,4, 12, 8,1, -23, 87,45, 12, 423 }; testQObj.LoadData(arrQ, sizeof(arrQ)/sizeof(int)); testQObj.Print(); testQObj.Sort(); cout << "Quick Sort Output:"; testQObj.Print(); HeapSort testHObj; int arrH[] = { 15,3,12,10,1,9,6,11,5,4, 12, 8,1, -23, 87,45, 12, 423 }; testHObj.LoadData(arrH, sizeof(arrH) / sizeof(int)); testHObj.Print(); testHObj.Sort(); cout << "Heap Sort Output:"; testHObj.Print(); QuickSortRandomized testQRObj; int arrQR[] = { 15,3,12,10,1,9,6,11,5,4, 12, 8,1, -23, 87,45, 12, 423 }; testQRObj.LoadData(arrQR, sizeof(arrQR) / sizeof(int)); testQRObj.Print(); testQRObj.Sort(); cout << "Heap Sort Output:"; testQRObj.Print(); HeapSortRevised testHSRObj; int arrHSR[] = { 15,3,12,10,1,9,6,11,5,4, 12, 8,1, -23, 87,45, 12, 423 }; testHSRObj.LoadData(arrHSR, sizeof(arrHSR) / sizeof(int)); testHSRObj.Print(); testHSRObj.Sort(); cout << "Heap Sort Output:"; testHSRObj.Print(); } catch (const std::exception& E) { cerr << "Caught exception \"" << E.what() << "\"\n"; } catch (...) { cerr << "Caught unknown exception"; } }