Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "SortFunctions.h"
- #include <iostream>
- using namespace std;
- int main() {
- int SIZE = 100;
- int selectionArray[SIZE];
- int selectionWorstCase[SIZE];
- int mergeArray[SIZE];
- int mergeWorstCase[SIZE];
- int selectionOperations = 0;
- int mergeOperations = 0;
- for(SIZE = 2; SIZE <= 100; SIZE++){
- for(int i = 0; i < 10000; i++){
- int tempOperations = 0;
- fillArray(selectionArray, mergeArray, SIZE);
- tempOperations = selectionSort(selectionArray, SIZE);
- if(tempOperations > selectionOperations){
- selectionOperations = tempOperations;
- }
- tempOperations = mergeSort(mergeArray, 0, SIZE - 1);
- if(tempOperations > mergeOperations){
- mergeOperations = tempOperations;
- }
- }
- cout << "The worst case for selection sort with array size " << SIZE << " is: " << selectionOperations << endl;
- cout << "The worst case for merge sort with array size " << SIZE << " is :" << mergeOperations << endl << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement