CS 1510 Midterm 2
Fall 2003
1. (20 points) We consider the problem of computing the longest common subsequence of two
sequences A = a1 , . . . , am and B = b1 , . . . , bn. Let T (i, j ) be the length of the longest common
subsequence of a1 , . . . , ai a
CS 1510
Parallel Algorithms Homework Problems
1. (2 Points) Consider the problem of computing the AND of n bits.
Give an algorithm that runs in time O(log n) using n processors on an EREW PRAM.
What is the eciency of this algorithm?
Using the folding p
CS 1510
Greedy Homework Problems
1. (2 points) Consider the following problem:
INPUT: A set S = cfw_(xi , yi )|1 i n of intervals over the real line.
OUTPUT: A maximum cardinality subset S of S such that no pair of intervals in S overlap.
Consider the fol
CS 1510
Dynamic Programming Homework Problems
1. (2 points) Consider the recurrence relation T (0) = T (1) = 2 and for n > 1
n1
T (i)T (i 1)
T (n) =
i=1
We consider the problem of computing T (n) from n.
(a) Show that if you implement this recursion direc
CS 1510
Approximiation Algorithms Problems
1. Consider the vertex cover problem, that is, given a graph G nd a minimal cardinality collection S of vertices with the property that every edge in G is incident to a vertex in S. Consider the following algorit
CS 1510 Midterm 1 Fall 2007
1. (40 points) You wish to drive from point A to point B along a highway minimizing the time that you are stopped for gas. You are told beforehand the capacity C of you gas tank in liters, your rate F of fuel consumption in lit
CS 1510
Adversarial Lower Bound Arguments
1. In a simplied form of the game mastermind there is a hidden sequence H = (c1 , . . . , ck ) of k colored pegs. There are C dierent possible colors. Colors can be repeated in the hidden sequence. The game consis
CS 1510 Midterm 1
Fall 2008
1. (40 points) We consider the following problem:
INPUT: A collection of jobs J1 , . . . , Jn , where the ith job is a 3-tuple (ri , xi, di) of non-negative
integers.
OUTPUT: 1 if there is a preemptive feasible schedule for the
CS 1510 Midterm 2
Fall 2008
1. (20 points) Consider the following two problems:
MATRIX MULTIPLICATION
INPUT: n by n matrices A and B
OUTPUT: The product AB
MATRIX SQUARING
INPUT: m by m matrix C
OUTPUT: The square of the matrix C
Assume that Matrix Multip
CS 1510 Midterm 1
Fall 2009
1. (40 points) We consider the following problem:
INPUT: A collection W of positive integer weights w1 , . . . , wn.
OUTPUT: A binary tree T with n leaves, where each leaf is labeled with a unique weight
w() from W , that minim
CS 1510 Midterm 2
Fall 2009
The test is a bit long. I suggest keeping your answers short and to the point.
1. (a) (5 points) According to your instructor, what is the most important reason that multiplicative constants are not taken into account when comp
CS 1510 Midterm 1
Fall 2010
1. (40 points) We consider the following scheduling problem:
INPUT: A collection of jobs J1 , . . . , Jn , where the ith job is a tuple (ri , xi ) of non-negative
integers specifying the release time and size of the job.
OUTPUT
CS 1510 Midterm 2
Fall 2010
The test is a bit long. I suggest keeping your answers short and to the point.
1. (a) (5 points) Consider the standard EREW algorithm for adding n integers that runs in time
T (n, p) = n/p + log p with p processors. Dene the ec
CS 1510 Midterm 1
Fall 2011
1. (40 points) Consider the following problem. The input is a collection A = cfw_a1 , . . . , an of n
points on the real line. The problem is to nd a minimum cardinality collection S of unit
length intervals that cover every p
CS 1510 Midterm 1
Fall 2011
1. (40 points) Consider the following problem. The input is a collection A = cfw_a1 , . . . , an of n
points on the real line. The problem is to nd a minimum cardinality collection S of unit
length intervals that cover every p
CS 1510
Reductions and NP-hardness Homework Problems
1. (2 points) A square matrix M is lower triangular if each entry above the main diagonal is zero, that
is, each entry Mi,j , with i < j, is equal to zero. Show that if there is an O(n2 ) time algorithm
CS 1510 Midterm 1: Greedy Algorithms
Fall 2003
1. (40 points) Consider the following problem. The input consists of n skiers with heights
p1 , . . . , pn , and n skies with heights s1, . . . , sn . The problem is to assign each skier a ski
to to minimize
CS 1510 Midterm 2
Fall 2010
The test is a bit long. I suggest keeping your answers short and to the point.
1. (a) (5 points) Consider the standard EREW algorithm for adding n integers that runs in time
T (n, p) = n/p + log p with p processors. Dene the ec
CS 1510 Midterm 1
Fall 2010
1. (40 points) We consider the following scheduling problem:
INPUT: A collection of jobs J1 , . . . , Jn , where the ith job is a tuple (ri , xi ) of non-negative
integers specifying the release time and size of the job.
OUTPUT
CS 1510 Midterm 2
Fall 2009
The test is a bit long. I suggest keeping your answers short and to the point.
1. (a) (5 points) According to your instructor, what is the most important reason that multiplicative constants are not taken into account when comp
CS 1510 Midterm 1
Fall 2009
1. (40 points) We consider the following problem:
INPUT: A collection W of positive integer weights w1 , . . . , wn.
OUTPUT: A binary tree T with n leaves, where each leaf is labeled with a unique weight
w() from W , that minim
CS 1510 Midterm 2
Fall 2008
1. (20 points) Consider the following two problems:
MATRIX MULTIPLICATION
INPUT: n by n matrices A and B
OUTPUT: The product AB
MATRIX SQUARING
INPUT: m by m matrix C
OUTPUT: The square of the matrix C
Assume that Matrix Multip
CS 1510 Midterm 1
Fall 2008
1. (40 points) We consider the following problem:
INPUT: A collection of jobs J1 , . . . , Jn , where the ith job is a 3-tuple (ri , xi, di) of non-negative
integers.
OUTPUT: 1 if there is a preemptive feasible schedule for the
CS 1510 Midterm 2
Fall 2007
1. (20 points) Consider the following problem. The input consists of n positive integers V =
cfw_v1 , . . . , vn . Let L = n vi . The problem is to determine if there are three disjoint subsets
i=1
S , P and T of V such that
3
CS 1510 Midterm 1
Fall 2007
1. (40 points) You wish to drive from point A to point B along a highway minimizing the time
that you are stopped for gas. You are told beforehand the capacity C of you gas tank in liters,
your rate F of fuel consumption in lit
CS 1510 Midterm 2
Fall 2005
1. (a) Dene EREW. That is, what properties must a PRAM program have to be EREW.
(b) Explain how to merge two sorted lists x1 , . . ., xn and y1 , . . . , yn of integers in time
O(log n) on an EREW PRAM using p = n processors.
(
CS 1510 Midterm 1
Fall 2005
Note that the only dierence in the rst two problems is the denition of total penalty.
1. The input to this problem consists of an ordered list of n words. The length of the ith word
is wi , that is the ith word takes up wi spac
CS 1510 Midterm 4
Fall 2003
1. (20 points)
(a) What is the most important reason that it is standard practice to ignore multiplicative
constants when computing running times of algorithms/programs?
HINT: Your answer should explain why we are not more prec
CS 1510 Midterm 3
Fall 2003
1. (20 points) Consider the following 3Clique problem:
INPUT: A undirected graph G and an integer k.
OUTPUT: 1 if G has three vertex disjoint cliques of size k, and 0 otherwise.
Show that this problem is N P -hard. Use the fact
CS 1510 Midterm 2
Fall 2010
1. (20 points) Consider the following two problems:
TRAVELING SALESMAN
INPUT: points (x1 , y1 ), . . . (xn , yn ) in the Euclidean plane
OUTPUT: The shortest route, starting from the origin, that visits all the points. You can