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++;
This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentPart 2: Analysis Coding
=======================
Now you will be measuring how the execution time and number of
This is the end of the preview.
Sign up
to
access the rest of the document.
 Spring '08
 LEBANON
 Algorithms, Filename, Computer file, Snippet, 59pm Assignment Overview

Click to edit the document details