Purchase Solution

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

Not what you're looking for?

Ask Custom Question

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.

Purchase this Solution

Solution Summary

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

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 ...

Purchase this Solution


Free BrainMass Quizzes
C# variables and classes

This quiz contains questions about C# classes and variables.

Javscript Basics

Quiz on basics of javascript programming language.

Word 2010: Table of Contents

Ever wondered where a Table of Contents in a Word document comes from? Maybe you need a refresher on the topic? This quiz will remind you of the keywords and options used when working with a T.O.C. in Word 2010.

C++ Operators

This quiz tests a student's knowledge about C++ operators.

Basic UNIX commands

Use this quiz to check your knowledge of a few common UNIX commands. The quiz covers some of the most essential UNIX commands and their basic usage. If you can pass this quiz then you are clearly on your way to becoming an effective UNIX command line user.