CS513 HW4 and 5
Erick Chastain, Ying Liu, Fengpeng Yuan, Kemal Guner, Daehan Kwak
March 7, 2011
HW 4, Q2) 1. The graph H is a DAG G , whose edges (u, v ) satisfy C (u) = C (v ) where C (x)
is the connected component containing node x. Because H is a DAG,
Lecture 12
Relation of NC to Time-Space Classes
Recall that NC is the class of sets computable by polylog-depth,
polynomial-size, logspace-uniform families of Boolean circuits C0 , C1 , . . . .
The following theorem relates this class to more conventional
Miscellaneous Exercises
The annotation H indicates that there is a hint for this exercise in the Hints
section beginning on p. 361, and S indicates that there is a solution in the
Solutions section beginning on p. 367. The number of stars indicates the
ap
HW 3, Due Feb 21.
1. You are given an array A[1, . . . , n] of nonnegative numbers and a target
W . A partition of array A into k pieces is given by l0 = 0 < l1 < l2 <
< lk = n. Design an algorithm to nd a partition of smallest
l +1
number of pieces such
Homework 2 Solutions
323
Homework 2 Solutions
1. If the function f is computable by a logspace transducer, then | f (x) | is
polynomial in | x |, because the transducer can run for at most polynomial time before repeating a conguration. Suppose f and g ar
326
Hints and Solutions
Homework 3 Solutions
1. (a) Let #L(x) (respectively, #R(x) be the number of left (respectively, right) parentheses in the string x. One can show by induction
that a string x is balanced i
(i)
(ii)
#L(x) = #R(x), and
for every prex
Homework 4 Solutions
329
Homework 4 Solutions
1. First assume A(n) and S (n) are space constructible. Let M be an A(n)alternation-bounded, S (n)-space-bounded machine. Let Cn be the set
of congurations of M on inputs of length n. There is a xed constant
c
332
Hints and Solutions
Homework 5 Solutions
1. Assume that p p . By Theorem 10.2, any set A p+1 can be
k
k
k
written
A
= cfw_x | y | y | | x |c R(x, y )
for some constant c, where R is a p -predicate. By the assumption, R
k
is also a p -predicate, hence
334
Hints and Solutions
Homework 6 Solutions
1. (a) If S (n) is space-constructible, there is a machine M that on any
input of length n lays o exactly S (n) space on its worktape without using more than S (n) space and halts. If M has q states and
d workt
Homework 7 Solutions
337
Homework 7 Solutions
1. The problem is PSPACE -complete. Because every nontrivial rst-order
theory is PSPACE -hard (Miscellaneous Exercise 49), the interesting
part is showing that it is in PSPACE .
For k -tuples a1 , . . . , ak a
Homework 8 Solutions
343
Homework 8 Solutions
1. The following nondeterministic Bchi automaton accepts all and only
u
(characteristic functions of) nite subsets of . It guesses when it has
seen the last 1 in the input string, and then enters a nal state,
CS513DesignandAnalysisofData
StructuresandAlgorithms
HW3
ErickChastain
DaehanKwak
FengPengYuan
YingLiu
KemalGner
Prob 1
We are given an array A[1, , n] and a target W. Array A is partitioned into k pieces l0=0
< l1 < l2 < < lk=n.
We use greedy algorithm
Homework 1 Solutions
319
Homework 1 Solutions
1. (a) One possible nonregular set accepted in time O(n log n) is
n
cfw_ a2 | n 0 .
Repeatedly scan the input, checking that the number of as remaining is even and erasing every second one, until one a remain
282
Exercises
Homework 7
1. Determine the complexity of the rst-order theory of the structure
(, ), where is the set of natural numbers and is the usual linear
order on .
2. Consider the following EhrenfeuchtFraiss game Gn between two playe
ers, Sonja (al
HW 2, Due March 7.
1. Say each edge has an integer weight from [1, n] on an n-node graph.
How much time do the various SSSP and APSP algorithms discussed
in the class take? State and prove the complexities.
2. (a) Consider a directed graph G and derive a
Homework 8
283
Homework 8
1. Show that the set of nite subsets of , represented as a set of strings
u
in cfw_0, 1 , is accepted by a nondeterministic B chi automaton, but by
no deterministic Bchi automaton. (Recall that in Bchi acceptance,
u
u
F Q, and a
HW 2, Due March 7.
1. Solve the global min-cut problem discussed in the class by using the
maxow problem. How many instances of the maxow problem do you
need to solve to global min-cut problem?
2. Given a biparite graph G = (L, R, E ) where L is the set o
284
Exercises
Homework 9
1. Given a sentence of the rst-order language of number theory (addition
and multiplication allowed) and a number n 2 in binary, what is the
complexity of determining whether holds in the ring Zn of integers
modulo n? Give proof.
CS513: Homework 1 Solutions
Instructor: S. Muthukrishnan, TA: D. Desai
February 28, 2011
1. The correct order is
2 log log n
n1000/ log n , 2
, log n, 0.001n3 , (n + 1)!, 22
n
+log n
n
, n 22 .
Here, one can use the trick x = 2log x . The rst function is
Homework 10
285
Homework 10
1. Using the sm functions and the universal function U , construct total
n
recursive functions pair and const such that
pair(i,j )
=
<i , j >
const(i)
=
i .
The construction should be similar to the construction of comp given i
CS513: Homework 2 Solutions
Instructor: S. Muthukrishnan, TA: D. Desai
February 28, 2011
1. Let (n) denote the number of primes before n. Then the number of primes in the interval [x, y ] is
(y ) (x). So the probability that a uniformly random number cho
286
Exercises
Homework 11
1. The jump operation ( ) is dened as follows:
A
= K A = cfw_x | A (x) .
x
This is the halting problem relativized to A. Dene
A(0)
(n+1)
A
=A
= (A(n) ) .
Show that (n) is m -complete for 0 , n 1.
n
2. (a) Show that if A is m -com
CS 513 - Design and Analysis of Data
Structures and Algorithms
HW1
Daehan Kwak
FengPeng Yuan
Ying Liu
Kemal GUner f/L"
java g :h x
,3 {6m}: . ~ 9 (4? V 7:7 7 y K)
L; r u
an , 0(0»?r:vx'x._;1:00w»!>:om"+%:9m£§
(j I.
g, w, ~ I) x , W
frié [{gy" \j" (1
5/
Homework 12
287
Homework 12
1. (a) Show that for every IND program over the natural numbers, there is
an equivalent IND program with simple assignments y := e(y) but
without existential assignments y := . (Hint. Convert countable
existential branching to
ms M3 - Design and Amalyi of Data
Structures. and Algmrithms
' HW 2
Daehan Kwak
FengPeng Yuan
Ying Liu
Kemal Gl'Jner Solution to Prob. 1
Algorithm: randomly choose a number h between [x, y], and pass h through blackbox to check
Whether h is prime. If the