CS 473
Headbanging 2 (September 1011)
Fall 2013
1. A longest common subsequence of a set of strings cfw_Ai is a longest string that is a subsequence of Ai
for each i. For example, alrit is a longest common subsequence of strings
algorithm
and
altruistic.
CS 473
Homework 8 (due November 5 2013)
Fall 2013
1. Let G = (V, E) be a directed graph with nonnegative real weights on edges. Each edge has a color
chosen from cfw_RED, WHITE, BLUE. An American path is a path in G that cycles through the colors in
order
CS 473
1.
HW0 solutions
Fall 2013
(a) Prove that every balanced string is erasable.
(b) Prove that every erasable string is balanced.
Solution (separate proofs with helpful lemmas):
(a) We prove the result in several stages.
Lemma 1. For any erasable stri
CS 473
Headbanging 9 Oct. 29/30
Fall 2013
1. Consider a path between two vertices s and t in an undirected weighted graph G. The bottleneck
length of this path is the maximum weight of any edge in the path. The bottleneck distance between
s and t is the m
Headbanging Nov. 04/05
CS 473
Fall 2013
1. AMORTIZED ANALYSIS. [Fall 2002, Spring 2004]
Suppose we want to maintain a set X of numbers, under the following operations:
INSERT(x): Add x to the set (if it isnt already there).
PRINT&DELETEBETWEEN(a, b): Pr
CS 473
Headbanging 8 Oct. 22/23
Fall 2013
1. Let G be an undirected graph.
(a) We put two coins on two arbitrarily chosen nodes. At every step, each coin must move to an
adjacent node. Describe an algorithm to compute the minimum number of steps to reach
CS 473
Headbanging 7 Oct. 15/16
Fall 2013
1. Recall the staircase problem from the midterm:
Let P be a set of n points in the plane. The staircase of P is the set of all points in
the plain that have at least one point in P both above and to the right.
De
CS 473
Headbanging 6 Oct. 08/09
Fall 2013
1. Suppose you have an interface for a STACK with the following operations implemented in constant
time:
(a) PUSH pushes an element on top of the stack.
(b) POP removes the top element from a stack.
(c) EMPTY crea
CS 473
Headbanging 4 (October 12)
Fall 2013
Note: All the questions in this session are taken from past CS473 midterms.
1. (Fall 2006) Multiple Choice: Each of the questions on this page has one of the following ve
answers: For each question, write the le
CS 473
Headbanging 5
Fall 2013
1. Suppose you have an interface for a STACK with the following operations implemented in constant
time:
(a) PUSH pushes an element on top of the stack.
(b) POP removes the top element from a stack.
(c) EMPTY creates a new,
CS 473
Headbanging 3 (September 2526)
Fall 2013
1. A vertex cover of a graph is a subset S of the vertices such that every vertex v either belongs to S
or has a neighbor in S. In other words, the vertices in S cover all the edges. Finding the minimum
size
CS 473
Headbanging 1 (September 34)
Fall 2013
1. An inversion in an array A[1 . n] is a pair of indices (i, j) such that i < j and A[i] > A[ j]. The
n
number of inversions in an n-element array is between 0 (if the array is sorted) and 2 (if the
array is
CS 473: Undergraduate Algorithms, Fall 2013
Headbanging 0: Induction!
August 28 and 29
1. Prove that any non-negative integer can be represented as the sum of distinct powers of 2. (Write
it in binary is not a proof; its just a restatement of what you hav
CS 473
Headbanging 8 Oct. 22/23
Fall 2013
1. Let G be a directed graph with a special source that has an edge to each other node in graph,
and denote scc(G) as the strong component graph of G. Let S and S be two strongly connected
components in G with S S