hw01-Fall09

hw01-Fall09 - CS2134 Fall 2009 sections A and B Profs...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
CS2134 Fall 2009 sections A and B Profs Frankl and Hellerstein Homework #1 Due 11:59 p.m., Friday Sept 25 Your first assignment has a programming portion and a written portion. Programming Part: In this assignment, you will examine the running time of several code fragments as a function of the size of their inputs (a vector parameter). Functions f1, …, f5 in the file hw01sample.cpp do simple (silly) computations involving loops. For each of these functions and for several sizes of the input vector, you will measure the number of times the (inner-most) loop is iterated and the actual execution time. The number of iterations can be measured by adding a counter variable and incrementing it each time the loop is executed. The function f1_count() illustrates how to do this for function f1. The execution time can be measured using a timer class, which is provided. However, in some cases the functions will execute so quickly that the timer class will report execution time equal to zero. To address this, you can start the timer, execute the code fragment many times, then divide the elapsed time by the number of times the code fragment was executed. The function f1_time illustrates how to do this for function f1. Note that the number of repeats is passed as an additional parameter. The main program in hw01sample.cpp measures the number of iterations and the execution time for f1 on inputs of size 1024 and 2048. Note that f1_time is executed with 1000 repeats for size 1024 and with 100 repeats for size 2048. In addition, it outputs the measured time divided by the vector size, n. If f1 has
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/02/2011 for the course CS 2134 taught by Professor Hellerstein during the Fall '07 term at NYU Poly.

Page1 / 4

hw01-Fall09 - CS2134 Fall 2009 sections A and B Profs...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online