Home | | Syllabus | | Assignments | | Lecture Notes
#include < ctime> #include < iostream> #include < iomanip> #include < cmath>The < cmath > library includes the pow() and log() functions that may prove useful to you.
The < ctime > library includes a function clock() that returns the number of clock ticks elapsed since the program was launched. Therefore, you may use the following code to measure how much time the for loop takes and store it in the variable, difference.
int start_clock = clock();
for (i = 0; i < n; i++)
result = result + result;
int difference = clock() - start_clock;
After you examine your program's results, answer the following questions:
Show your work and explain your answers. For example, for problem E2, indicate the appropriate rule or show the limit that lets you place one function above or below another in your list of functions. Also indicate which is fastest and which is slowest.
Home | | Syllabus | | Assignments | | Lecture Notes
Computer Science 132--Data Structures
Last Modified: February 5, 2010
Page Expires: January 14, 2011