Implement a bubble sort that accepts an array of integers a, and an integer aSize, and sorts a in DECENDING order. Determine the execution speed for your bubble sort as the array length increases from 100 to 1000, 10000, 100000, and 250000 elements. Use the attached code fragment to time your bubbleSort function. Place a brief, but well-written summary of your results in the .cpp file.
9. using c++,
Implement a bubble sort that accepts an array of integers a, and an integer aSize, and sorts a in DECENDING order. Determine the execution speed for your bubble sort as the array length increases from 100 to 1000, 10000, 100000, and 250000 elements. Use the attached code fragment to time your bubbleSort function.
Place a brief, but well-written summary of your results in the .cpp file.
#include <iostream>
#include <ctime>
#include <thread>
using namespace std;
int main() {
int x = 0, y = 100000;
// get starting value of timer
clock_t start = std::clock();
//code to be timed goes here
do_something();
// get ending value of timer
clock_t end = std::clock();
std::cout << (double)(end - start) / CLOCKS_PER_SEC << std::endl;
}
Implement a bubble sort that accepts an array of integers a, and an integer aSize, and sorts a in DECENDING order. Determine the execution speed for your bubble sort as the array length increases from 100 to 1000, 10000, 100000, and 250000 elements. Use the attached code fragment to time your bubbleSort function.
Step by step
Solved in 2 steps