Package edu.princeton.cs.algs4
Class StopwatchCPU
 Object

 edu.princeton.cs.algs4.StopwatchCPU


Constructor Summary
Constructors Constructor Description StopwatchCPU()
Initializes a new stopwatch.

Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description double
elapsedTime()
Returns the elapsed CPU time (in seconds) since the stopwatch was created.static void
main(String[] args)
Unit tests theStopwatchCPU
data type.



Method Detail

elapsedTime
public double elapsedTime()
Returns the elapsed CPU time (in seconds) since the stopwatch was created. Returns:
 elapsed CPU time (in seconds) since the stopwatch was created

main
public static void main(String[] args)
Unit tests theStopwatchCPU
data type. Takes a commandline argumentn
and computes the sum of the square roots of the firstn
positive integers, first usingMath.sqrt()
, then usingMath.pow()
. It prints to standard output the sum and the amount of time to compute the sum. Note that the discrete sum can be approximated by an integral  the sum should be approximately 2/3 * (n^(3/2)  1). Parameters:
args
 the commandline arguments

