CS6505: Computability & Algorithms
Homework 6 Solutions.
Prove that the following decision problems are NP-complete.
1. Given two graphs G1 , G2 and an integer k , determine whether there exists a graph H with
at least k edges such that H is contained in
CS6505 Computability, Algorithms, and Complexity
Homework 1: Due Friday, August 31, 2012
(Total 60 points)
1. (15 points) A verier is a deterministic Turing machine V that is a decider that takes two arguments
x (the input) and y (the proof).
Show that a
CS6505: Computability & Algorithms
Homework 1 Solutions.
1. Countability.
(a) Since S1 and S2 are countable, there exists a bijection f1 : S1 N and f2 : S2 N .
To prove that S1 S2 is countable, we need to dene a bijection g : N N N .
The bijection N N N i
Time Complexity for DTMs
M is a 1-tape DTM that halts on all inputs.
The time taken by M on an input w is the number of steps M uses to accept or reject.
The running time of M is a function of the input length:
the maximum of the time taken by M on any i
#Consider the language E over the binary alphabet
#consisting of strings representing even non-negative
#integers (with leading zeros allowed).
#I.e. E = cfw_x | x[-1] = '0'.
#
#Reduce E to the language cfw_'Even' by implementing
#the function R
def R(x)
CS6505: Computability & Algorithms
Homework 10.
Due in class on Fri, Apr 6.
1. Consider the following greedy algorithm for nding a maximum matching: Start with an
arbitrary edge as the initial matching. Find another edge that does not have a vertex in
com
CS6505 Computability, Algorithms, and Complexity
Fall 2012/Homework 2
Due on: Friday, September 21, 2012
1. (15 points) Let Sk = cfw_ M , k | M is a 1 tape DTM and L(M ) has k strings.
Show that ATM m Sk .
Solution: Here is one reduction.
On input M , w ,
# Given two sets A and B of integers, their sum set C is defined to be
# C = cfw_a+b: aA, bB. For each c \in C, let m(c)denote the number of ways in
# which c can be obtained, i.e., m(c) = |cfw_(a,b) : a A, b B, a+c = c|.
# For example, if A = cfw_1,2,3
#This exercise asks you to solve a problem using
#a maximum flow algorithm as a subroutine. For
#this purpose, you may use the provided maximumflow
#module, which contains the following three functions
#
#(flow,cut) = maxflow_mincut(C,s,t):
# C is assum
CS6505 Computability, Algorithms, and Complexity
Homework 1: Due Friday, August 31, 2012
(Total 60 points)
1. (15 points) A verier is a deterministic Turing machine V that is a decider that takes two arguments
x (the input) and y (the proof).
Show that a
CS6505 Computability, Algorithms, and Complexity
Homework 1 solutions sketch. 1. (15 points) Consider the simulation of a multitape Turing machine M by a single-tape Turing machine S as described in the proof of Theorem 3.13 in the text. Let k = 2. (a) Gi
CS6505 Computability, Algorithms, and Complexity
Fall 2012/Homework 2
Due on: Friday, September 21, 2012
1. (15 points) Let Sk = cfw_ M , k | M is a 1 tape DTM and L(M ) has k strings.
Show that ATM m Sk .
2. (15 points) Let L = cfw_ M | L(M ) is innite .
CS6505 Computability, Algorithms, and Complexity
Fall 2012
TEST 1
Total 60 points
NAME:
NOTES:
Read all the questions. Questions on pages 2, 3, 4, and 5.
You can bring a sheet with notes on both sides. You may not use any other source.
You can use with
#This exercise asks you to solve a problem using
#a maximum flow algorithm as a subroutine. For
#this purpose, you may use the provided maximumflow
#module, which contains the following three functions
#
#(flow,cut) = maxflow_mincut(C,s,t):
# C is assum
CS6505: Computability & Algorithms
Homework 8 Solutions
1. Given a graph G, a vertex cover is a set S of vertices so that every edge in G has at least one
endpoint in S . Consider the following randomized algorithm for nding a small vertex cover:
Start wi
CS6505: Computability & Algorithms
Homework 7 Solution.
1. You are given two n n matrices, with n = 2k for some natural number k , such that each
matrix has the following recursive structure: when divided into four equal-size blocks, the
two diagonal bloc
CS6505: Computability & Algorithms
Homework 5 Solutions.
1. Let G = (V, E ) be a graph with nonnegative edge weights w(u, v ) for each edge (u, v ) E ,
and s, t be a pair of nodes in G. The weight of a path from s to t is dened as the maximum
of the weigh
CS6505: Computability & Algorithms
Homework 4 Solutions.
1. Given a graph G, a matching in G is a set of edges such that no two of them share a vertex.
Let MATCHING = cfw_(G, k ) : G has a matching of size k , i.e., the language consisting of
graphs G wit
#Consider the language A = cfw_'John'. Reduce
#A to the complement of A by implementing
#the function R.
def R(x):
#Your code here
def A(x):
if x = 'John':
return '
return 'John'
return A(x)
def main():
#A few test cases
assert(R('John') not in ['
#Your task is to reduce the language cfw_'Jane'.
#to the halting problem cfw_<M> | M halts on the empty string.
#
#Since we can't very well test whether your output function
#actually loops, we ask you to raise the exception Looping
#defined below with
#
CS 6505O01, O3
Homework 3
Fall 2015
Directions: This problem set contains material from Lesson 6 (P and NP), Lesson
7 (NP-completeness), and Lesson 8 (NP-complete Problems).
This assignment is due on Monday, September 28, at 8:00 a.m. U.S. Eastern
Time. T
1.
An instance of the subgraph isomorphism problem consists of two graphs
G1=(V 1 , E1 ) and G2=(V 2 , E2 ) . In a positive instance, G2 is isomorphic to a
G1 . That is to say, there is a subset V ' V 1 and a bijection
f : V 2 V ' such that (u , v ) E2 if
1.
Describe how you might use nondeterminism to simplify the construction of a Turing
machine that performs the following tasks.
a. Decide the language cfw_www is a binary string
b. Recognizes the language cfw_<M> | M accepts some string
2.
Construct a S
1.
An instance of the half 3-CNF satisfiability problem is a collection of m clauses each
having 3 literals. A positive instance is one where there exists an assignment that
makes exactly of the clauses evaluate to True.
Prove that half 3-CNF SAT is NP-Co
1.
Suppose that you are the instructor for an algorithms course. As part of an assignment,
you have asked your students to write code that returns a longest palindromic
subsequence of a string. When you realize this means that you have grade more than
200
1.
Suppose that a flow network (V , E ,c , s ,t ) admits a flow f , where v ( f )> 0 .
a. Show that the network must have positive flow path. That is to say, there is an st path p where f (u , v)>0 , for every (u , v ) p .
b. Consider a flow f ' , where f
CS 6505Section O01
Homework 0
Fall 2015
Directions: This problem set covers background material for the course: logic, set
theory, induction, and asymptotic analysis. You may nd it useful to consult Ken
Rosens textbook Discrete Math and Its Applications.
CS 6505Section O01
Homework 1
Fall 2015
This problem set contains material from Lesson 1 (Languages & Countability) and
Lesson 2 (Turing Machines).
This assignment is due on Monday, August 31, at 8:00 a.m. U.S. Eastern Time.
Turn in your answers for Probl
Last Name: . First Name: . Email: .
CS 6505, Fall 2017, Homework 2, Sept 8 Due Sept 15 in class Page 1/10
Problem 1: Dynamic Programming, Max Sum Contiguous Subsequence (10 points)
A contiguous subsequence of a list S is a subsequence made up of consecuti
Algorithm 3 Hotel stops(a1 , a2 , . . . , an )
P (0) = 0
for i = 1 to n do
P (i) = (200 ai )2
prev(i) = N U LL
for k = 1 to i 1 do
if P (i) > P (k) + (200 (ai ak )2 then
P (i) = P (k) + (200 (ai ak )2
prev(i) = k
end if
end for
end for
cfw_*P (n) is the m
mi is included, we have that P (i) = pi +P (last(i). Therefore, the recurrence
is the following:
P (i) = maxcfw_P (i 1), pi + P (last(i)
It is easy to modify the earlier pseudocode to obtain an O(n2 ) time solution. In fact, by first calculating last(i) f
Solutions for [DPV] Practice Dynamic Programming Problems
[DPV] Problem 6.8 Longest common substring
Solution:
Here we are doing the longest common substring (LCStr), as opposed
to the longest common subsequence (LCS). First, we need to figure out the
sub
Algorithm 2 Coin Changing I
S(0) = TRUE.
for j = 1 to v do
S(j) = FALSE.
end for
for i = 1 to v do
for j = 1 to n do
if i xj 0 then
S(i) S(i xj ) S(i)
end if
end for
end for
return S(v)
[DPV] Problem 6.18 Making change II
Solution: This problem is very si