我正在对quicksort(来自c++ STL的qsort)算法进行分析,代码为:
#include <iostream>
#include <fstream>
#include <ctime>
#include <bits/stdc++.h>
#include <cstdlib>
#include <iomanip>
#define MIN_ARRAY 256000
#define MAX_ARRAY 1000000000
#define MAX_RUNS 100
using namespace std;
int* random_array(int size) {
int* array = new int[size];
for (int c = 0; c < size; c++) {
array[c] = rand()*rand() % 1000000;
}
return array;
}
int compare(const void* a, const void* b) {
return (*(int*)a - *(int*)b);
}
int main()
{
ofstream fout;
fout.open("data.csv");
fout << "array size,";
srand(time(NULL));
int size; …Run Code Online (Sandbox Code Playgroud)