04/11/2009
CMPE 300 ANALYSIS OF ALGORITHMS
ASSIGNMENT #1
Please answer the following questions and submit your answers to your assistant until 17:00
XXXXXXXXXXXX. The sole purpose of this homework is to familiarize you with the
processes involved in answe

CMPE 300 ANALYSIS OF ALGORITHMS
MIDTERM ANSWERS
1. A basic operation is called realistic if the actual execution time on some computer is bounded by
a linear function of the derived (analyzed) complexity.
Realistic basic operation
Basic operation not real

CMPE 300 ANALYSIS OF ALGORITHMS
MIDTERM
18.11.2009
1. You are given the following function of n:
f ( n) n 3 log(n!)
n
Use Stirlings approximation ( n!
n
2n , for large n) to simplify f(n) and determine
e
whether the following are true or false. Justify

CMPE 300 ANALYSIS OF ALGORITHMS
MIDTERM ANSWERS
1. (See Answer 1 in Assignment #1)
2. Harmonic series is a nonincreasing function. By applying the integration formula for
nonincreasing functions, we get
n+1 1
1
x
n
dx H(n)
n+1
0
1
dx
x
n
ln x 1 H(n) ln

CmpE 300 - Assignment 2
Please answer the following question and submit your answer to your assistant until
January 11th. Please do not just submit an answer, but show your reasoning, and how you arrive at
the answers. For any further questions, contact t

1
I. C MP E 300 H OMEWORK I A NSWERS
A. Question I
f (n) is given as:
f (n) = n3 log(n!)
(1)
and Stirlings approximation is as follows:
nn
en
Using Stirlings approximation, we can nd an approximate value for f (n).
n!
2n
(2)
1
1
f (n) n4 log(n) n4 log(e)

CMPE 300 ANALYSIS OF ALGORITHMS
FINAL
15.01.2010
1. One way of designing a probabilistic algorithm is randomizing a given deterministic
algorithm (i.e. by inserting some random commands, converting it into a probabilistic
algorithm). Suppose that A is a g

CMPE 300 ANALYSIS OF ALGORITHMS
FINAL
11.8.2009
1. a) Explain the three main approaches of designing parallel algorithms. Explain briefly and
give an example for each.
b) As we know, a parallel algorithm is cost optimal if C(n)=W*(n). What is the reason b

CMPE 300 ANALYSIS OF ALGORITHMS
FINAL ANSWERS
1.
a) The first approach is, given a sequential algorithm, converting it into a parallel algorithm.
We change the code of the sequential algorithm such that those parts that are
parallelizable will be executed

CMPE 300 ANALYSIS OF ALGORITHMS
FINAL ANSWERS
1. This technique is used for deterministic algorithms for which W(n) is much larger than
A(n). By converting it to a probabilistic algorithm, we try to make W exp(n) as close to A(n)
as possible. If Wexp(n) c

Cmpe 300 - Analysis of Algorithms
Fall 2010
Assignment 1
Due Date: 03/11/2010 17:00
Question 1 (60 Points)
Consider the following function which takes X (a stream of 0s and 1s, whose length is n) as input.
X
=
x0
x1
= xi cfw_0, 1,
X[i]
function Q1(X)
Inpu

CMPE 300 ANALYSIS OF ALGORITHMS
ASSIGNMENT #2 ANSWERS
1. a)
procedure ReverseEREW (L[1:n])
n
Model: EREW PRAM with p=
processors
2
Input: L[1:n] (a list of size n)
Output: L[1:n] (the input list in reverse order)
n
for 1i in parallel
do
2
L[n-i+1] =

CMPE 300 ANALYSIS OF ALGORITHMS
ASSIGNMENT #2
23.7.2009
1. We have a list of data L[1:n] and we want to reverse the elements in the list. For instance,
if the input list is [10 20 30 40 50 60 70 80], the output list will be [80 70 60 50 40 30 20
10].
a) W

CMPE 300 ANALYSIS OF ALGORITHMS
ASSIGNMENT #1 ANSWERS
1.
a) (i) Number of integers (n)
(ii) Addition
(iii) Not different. Independent of the nature of the input, the same number of
operations will be performed.
b) (i) Size of the list (n)
(ii) Comparison

CMPE 300 ANALYSIS OF ALGORITHMS
ASSIGNMENT #1
7.7.2009
1. For each of the following algorithms, indicate (i) a natural size metric for its inputs; (ii) its
basic operation; (iii) whether the basic operation count can be different for inputs of the
same si

CMPE 300 ANALYSIS OF ALGORITHMS
MIDTERM
23.7.2009
1. Give the definition of realistic basic operation. Then, give a general explanation of this
concept using graphs that is, draw a graph showing a realistic basic operation and draw a
graph showing a basic