Explore BrainMass
Share

Explore BrainMass

    Write a small program in C++ to time the given algorithm.

    This content was COPIED from BrainMass.com - View the original, and get the already-completed solution here!

    Write a small program in C++ to time the given algorithm.

    Algorithm: SUM[n=0 to 100] n(n x 3n)(n+1)/(77n - 4)

    Hint: you can use a timing function such as:
    clock_t begin = clock(); ... clock_t end = clock();

    See attachment for a better illustration of the math.

    © BrainMass Inc. brainmass.com October 10, 2019, 4:29 am ad1c9bdddf
    https://brainmass.com/computer-science/cpp/write-small-program-time-algorithm-463534

    Attachments

    Solution Preview

    We will use the ctime library function clock() to time the algorithm. The clock() function counts the number of "clock ticks" (CPU time) elapsed since the program was started. The return type of clock() is clock_t, which is defined by ctime to represent clock ticks and supports arithmetical operations (usually long integer ...

    Solution Summary

    The expert writes a small program in C++ to time the given algorithm.

    $2.19