SHARE
TWEET

Untitled

a guest Mar 18th, 2019 47 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "SortFunctions.h"
  2. #include <iostream>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7.     int SIZE = 100;
  8.     int selectionArray[SIZE];
  9.     int selectionWorstCase[SIZE];
  10.     int mergeArray[SIZE];
  11.     int mergeWorstCase[SIZE];
  12.     int selectionOperations = 0;
  13.     int mergeOperations = 0;
  14.  
  15.  
  16.     for(SIZE = 2; SIZE <= 100; SIZE++){
  17.         for(int i = 0; i < 10000; i++){
  18.             int tempOperations = 0;
  19.  
  20.             fillArray(selectionArray, mergeArray, SIZE);
  21.  
  22.             tempOperations = selectionSort(selectionArray, SIZE);
  23.             if(tempOperations > selectionOperations){
  24.                 selectionOperations = tempOperations;
  25.             }
  26.  
  27.             tempOperations = mergeSort(mergeArray, 0, SIZE - 1);
  28.             if(tempOperations > mergeOperations){
  29.                 mergeOperations = tempOperations;
  30.             }
  31.         }
  32.         cout << "The worst case for selection sort with array size " << SIZE << " is: " << selectionOperations << endl;
  33.         cout << "The worst case for merge sort with array size " << SIZE << " is :" << mergeOperations << endl << endl;
  34.     }
  35. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top