COMS 4231: Analysis of Algorithms I, Fall 2012
Problem Set 2, due Thursday October 4, in class
Please follow the homework submission guidelines posted on the web
Problem 1. Solve the following recurrences asymptotically. For each recurrence show
T(n)=f(n)

Solutions: Homework 2
CSOR W4231: Analysis of Algorithms I
Fall 2015
Problem 1
(graded by Nivvedan)
(a)
T (n) = 9T (n/3) + n2
Master Theorem can be applied to this recurrence relation. a = 9, b = 3 here.
nlogb a = n2 . By case 2 of the Masters theorem, T

Solutions: Homework 1
CSOR W4231: Analysis of Algorithms I
Fall 2015
Problem 1
(Graded by Nivvedan)
(a)
f (n) = 3n3 + 2n2 + 5n + 2; g(n) = (n2 1)2
We saw in class that a polynomial of degree d is (nd ).
f (n) is a third-degree polynomial whose highest ter

Analysis of Algorithms
Solutions to Problem Set #1
Problem 1 (graded by Dan)
(a)
O, , and because both f and g are polynomials of degree 3, i.e. they both are
(n3 ).
(b)
O, , and because g (n) = 2n+5 = 25 2n = 32 2n = (2n ).
(c)
o and O because f (n) = 23

Analysis of Algorithms HW4
Rajan bhargava
Instructor: Prof. Eleni Drinea
April 14, 2016
1
Problem 1
This algorithm is a modified BFS, starting at node v. For each node u processed by
BFS, we record two values: the number of shortest v-u paths u.num, and t

CSOR W4231.002 Spring, 2016
Homework 1
Out: Monday, January 25, 2015
Due: 8pm, Monday, February 8, 2015
Please keep your answers clear and concise. Collaboration is limited to discussion of ideas
only. You should write up the solutions entirely on your ow

COMS 4231: Analysis of Algorithms I, Fall 2012
Problem Set 3, due Thursday October 18, in class
Note: We plan to post solutions on Friday October 19, in preparation
for the midterm, so no homeworks will be accepted after Friday 1pm.
Please follow the home

3 IowveworK A
My y32867 Yao Song
6b,? ,- b3; Lh):"\,z {\lojba: ML”: 159(7QVH)
Thus by (use?) Tux): 0C“)
C T 3* " m 2n
m): IL'iVT [$85
azg, m ,n‘ vazn‘wzém )
3.
“Ms: A”? 5 ﬂ-KO‘I : A”: O (IL/Bf2 g) Wm fwﬂa’f
g /
5—Wwa by CM)? 1 , Tun: 9(11‘1585)
7U1)

Solutions: Homework 4
CSOR W4231: Analysis of Algorithms I
Fall 2015
Problem 1
(graded by Mengting)
Sol. We can solve this problem with a greedy algorithm. First, sort all the set of points with
O(nlogn) sorting algorithm s.t.
x1 x2 . xn
Then choose the s

COMS 4231: Analysis of Algorithms I, Fall 2015
Problem Set 2, due Thursday October 8, 11:40am on Courseworks
Please follow the homework submission guidelines posted on courseworks.
In all problems that ask you to give an algorithm, include a justification

COMS 4231: Analysis of Algorithms I, Fall 2015
Problem Set 4, due Thursday November 12, 11:40am in pdf format on
Courseworks.
Please follow the homework submission guidelines posted on courseworks.
As usual, for each of the algorithms that you give, inclu

Solutions: Homework 5
CSOR W4231: Analysis of Algorithms I
Fall 2015
Prof. Mihalis Yannakakis
Problem 1
(graded by Nivvedan)
By denition, a bipartite graph G is undirected and must have the property that its set
of N nodes can be partitioned into two subs

COMS 4231: Analysis of Algorithms I, Fall 2015
Problem Set 1, due Thursday September 24, 11:40am on Courseworks
Please follow the homework submission guidelines posted on
courseworks
For all algorithms that you give, show their correctness and analysis of

CSOR 4231: Final Practice Problems, Fall 2014
These problems are ungraded, and are intended as a study aid. Solutions will also be posted
on courseworks. They are very similar to the problems that will appear on the nal. The nal is
closed book, closed not

CSOR 4231: Midterm Practice Problems, Fall 2014
These problems are ungraded, and are intended as a study aid. Solutions will also be posted
on courseworks. They are very similar to the problems that will appear on the midterm. The
midterm is closed book,

CSOR W4231.002 Spring, 2016
Homework 5 solutions
1. (a) We can prove this using the accounting method introduced in part 17.2 in textbook.
Here we charge the operations as follows:
Setting a bit from 0 to 1: $3, while the actual cost is $1
Resetting a b

CSOR 4231: Midterm Practice Problems, Fall 2014
These problems are ungraded, and are intended as a study aid. Solutions will also be posted
on courseworks. They are very similar to the problems that will appear on the midterm. The
midterm is closed book,

CS4231: Analysis of Algorithms, I, Fall 2012
Final Exam, Thursday December 6, 2012
This exam ends at 12:55 PM. It contains 5 problems, some of them composed of several
parts. There are 100 points in all, and you have 75 minutes. Do not spend too much time

COMS 4231: Analysis of Algorithms I, Fall 2012
Problem Set 5, due Thursday November 15, in class
Please follow the homework submission guidelines posted on the web
As usual, for each of the algorithms that you give, include an explanation of how the
algor

Quicksort
CS 4231, Fall 2015
Mihalis Yannakakis
Quicksort
Based on divide and conquer
practical, fast,
sorts in place
Quicksort
Divide: Partition the input array A of
elements with respect to a pivot element x
into two parts:
x
x
x
Conquer: Sort recu

Heap Priority Queue
and Heapsort
CS 4231, Fall 2015
Mihalis Yannakakis
1
Priority Queue
Max-Priority Queue: Data structure for a set S of
items, each with a key (its priority)
Basic Operations:
Insert: insert item x ( S := S cfw_x)
Max: returns an ite

Randomization
CS 4231, Fall 2015
Mihalis Yannakakis
1
Randomized algorithms
Make random choices (coin flips, random numbers .)
Different random choices are assumed independent
Outcome of algorithm and running time depends on
random choices (besides inp

Counting Sort, Radix Sort
CS 4231, Fall 2015
Mihalis Yannakakis
1
Counting Sort
Restricted domain: D=cfw_1,k
Idea: Count how many input elements for each i in D
Example: Input A = [ 1, 2, 1, 3, 2, 5, 3, 2, 5]
Counts: C(1)=2, C(2)=3, C(3)=2, C(4)=0, C(5)

Selection
CS 4231, Fall 2015
Mihalis Yannakakis
1
Selection (Order Statistics)
Input: Set A of n numbers (or more
generally, elements from an ordered
domain), number i, 1in
Output: i-th smallest (rank i) element of A
i=1:
minimum
i=n:
maximum
i=(n+1)

Shortest Paths
CS 4231, Fall 2015
Mihalis Yannakakis
1
Shortest Paths
Given graph (directed or undirected) G=(N,E) with
lengths (or weights or costs) on the edges w: E R
Length of a path = sum of lengths of the edges.
shortest s-t path = path with mini

Solutions: Homework 3
CSOR W4231: Analysis of Algorithms I
Fall 2015
Problem 1
(Graded by Nivvedan)
In a min-heap, the min-heap property holds. That is, for each node l, except the root
node,
A[parent(l)] A[l]
The goal is to print out all elements in the

CSOR 4231 Final Exam
December 17, 2003, 9AM
Rules; Answer each question completely and concisely. When you give an
algorithm, be sure to give the most efficient one you can, to prove that it is
correct, and to analyze its running time. Any NP-completeness

CSOR 4231, Fall 2015
Problem Set 6 Solutions
Problem 1. Exercises 25.2-6. 25.1-10. All pairs shortest paths.
25.2-6
If any shortest-path distances from node i to itself, i.e., the main diagonal, becomes negative
then there is a path from i to itself, i.e.

CSOR 4231 Sketch of Solutions to Final Exam
December 17, 2003, 9AM
Rules; Answer each question completely and concisely. When you give an
algorithm, be sure to give the most efficient one you can, to prove that it is
correct, and to analyze its running ti

CSOR 4231, Fall 2015
Problem Set 5 Solutions
Problem 1. Exercises 22.2-6, 22.2-7, breadth first search.
Suppose we have a graph G = (V, E) and select a set of tree edges E E to form a new graph
G = (V, E ) as following:
S
S
a
b
a
b
c
d
c
d
G = (V, E)
G =

CSOR 4231 Midterm Exam
November 5, 2015, 4:10PM
Rules; Answer each question completely and concisely. When you give an
algorithm, be sure to give the most efficient one you can, to prove that it is
correct, and to analyze its running time.
Problem 1. [10