diff --git a/Codes/Code-2.cpp b/Codes/Code-2.cpp index 5fc0069..f3bc423 100644 --- a/Codes/Code-2.cpp +++ b/Codes/Code-2.cpp @@ -151,34 +151,44 @@ int main() { arr[i] = rand() % 10000; double start, end; + double time_seq_bubble, time_par_bubble; + double time_seq_merge, time_par_merge; // --- Sequential Bubble Sort --- vector seqArr = arr; start = omp_get_wtime(); sequentialBubbleSort(seqArr); end = omp_get_wtime(); - cout << "Sequential Bubble Sort time: " << (end - start) << " seconds" << endl; + time_seq_bubble = end - start; + cout << "Sequential Bubble Sort time: " << time_seq_bubble << " seconds" << endl; // --- Parallel Bubble Sort --- vector parArr = arr; start = omp_get_wtime(); parallelBubbleSort(parArr); end = omp_get_wtime(); - cout << "Parallel Bubble Sort time: " << (end - start) << " seconds" << endl; + time_par_bubble = end - start; + cout << "Parallel Bubble Sort time: " << time_par_bubble << " seconds" << endl; + + cout << "Bubble Sort Speedup (Sequential / Parallel) = " << (time_seq_bubble / time_par_bubble) << "x" << endl; // --- Sequential Merge Sort --- seqArr = arr; start = omp_get_wtime(); sequentialMergeSort(seqArr, 0, n - 1); end = omp_get_wtime(); - cout << "Sequential Merge Sort time: " << (end - start) << " seconds" << endl; + time_seq_merge = end - start; + cout << "\nSequential Merge Sort time: " << time_seq_merge << " seconds" << endl; // --- Parallel Merge Sort --- parArr = arr; start = omp_get_wtime(); parallelMergeSort(parArr, 0, n - 1); end = omp_get_wtime(); - cout << "Parallel Merge Sort time: " << (end - start) << " seconds" << endl; + time_par_merge = end - start; + cout << "Parallel Merge Sort time: " << time_par_merge << " seconds" << endl; + + cout << "Merge Sort Speedup (Sequential / Parallel) = " << (time_seq_merge / time_par_merge) << "x" << endl; return 0; }