CSE 331: Introduction to Algorithm Analysis and Design
Fall 2011
Homework 2
Due Friday, September 23, 2011 by 1:15pm in class
IMPORTANT: Please submit each problem separately, i.e. each problem should begin
on a new page and only the pages for one problem should be stapled together. Failure
to do so might result in some problem(s) not being graded.
For general homework policies and our suggestions, please see the policy document.
Sections 2.2 and 2.4 from the textbook might be useful for this homework.
For this homework, you can assume that addition, subtraction, multiplication and division of two
numbers can be done in
O
(1) time. (Side question: Is this assumption justiﬁed?)
Do not turn the ﬁrst problem in.
1. (
Do NOT turn this problem in
) This problem is just to get you thinking about asymptotic
analysis and input sizes.
An integer
n
≥
2 is a prime, if the only divisors it has is 1 and
n
. Consider the following
algorithm to check if the given number
n
is prime or not:
For every integer 2
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
This is the end of the preview.
Sign up
to
access the rest of the document.
 Fall '11
 RUDRA
 Big O notation, Analysis of algorithms, Asymptotic analysis, Algorithm Analysis and Design

Click to edit the document details