HW4 - HW4 Analysis and More Due: Friday, September 19, 2008...

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

View Full Document Right Arrow Icon
HW4 Analysis and More Due: Friday, September 19, 2008 at 11:59pm Assignment Overview =================== This is a three part assignment, covering algorithm analysis and reading input files. Part 1: Algorithm Analysis ========================== Consider the following code segments. Determine the runtime (ie BigO) of each snippet by examining the code structure, and explain your reasoning in a couple sentences. Put your answers in a text file named „analysis.txt‟ . Snippet 1 sum = 0; for(i = 0; i < n; i++) sum++; Snippet 2 sum = 0; for(i = 0; i < n; i++) for(j = 0; j < n; j++) sum++; Snippet 3 sum = 0; for(i = 0; i < n; i++) for(j = 0; j < n * n; j++) sum++; Snippet 4 sum = 0; for(i = 0; i < n; i++) for(j = 0; j < i; j++) sum++; Snippet 5 sum = 0; for(i = 0; i < n; i++) for(j = 0; j < i * i; j++) for(k = 0; k < j; k++) sum++; Snippet 6 sum = 0; for(i = 1; i < n; i++) for(j = 1; j < i * i; j++) if(j % i == 0) for(k = 0; k < j; k++) sum++;
Background image of page 1

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

View Full DocumentRight Arrow Icon
Part 2: Analysis Coding ======================= Now you will be measuring how the execution time and number of
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 2

HW4 - HW4 Analysis and More Due: Friday, September 19, 2008...

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