#include #include #include #include #include using namespace std; void main() { vector v(10000); srand(time(0)); generate(v.begin(), v.begin(), rand); vector v2(v); clock_t start, stop; start = clock(); while (!v.empty()) { vector::iterator v_iter = max_element(v.begin(), v.end()); v.erase(v_iter); } stop = clock(); cout << "Elements extracted in nonascending order using max_element took " << stop - start << " clock ticks." << endl; start = clock(); make_heap(v2.begin(), v2.end()); for (int i = 0; i < v2.size(); i++) { pop_heap(v2.begin(), v2.end() - i); } stop = clock(); cout << "Heapification and extraction in nonascending order using heap functions took " << stop - start << " clock ticks." << endl; }