// timing using system clock #include #include #include "heapsort.h" #define Size 100000 void main(void) { int a[Size], step = 10000; clock_t start, finish; cout << "1 tick = 1 / CLK_TCK seconds " << endl; cout << "CLK_TCK of this machine is: " << CLK_TCK << endl; cout << endl; cout << "heap sort: O(n ln(n))" << endl; cout << endl; cout << "array size n " << "time " << endl; cout << endl; for (int n = 0; n <= Size; n += step) { // start to measure time for size n for (int i = 0; i < n; i++) a[i] = n - i; // initialize start = clock( ); HeapSort(a, n); finish = clock( ); if (n) cout << n << " " << (finish - start) / CLK_TCK << endl; } }