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 ,
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
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 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
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
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
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
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
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
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
#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
#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 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 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
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
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
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
#Consider an arbitrary string X = x_1.x_n.
#A subsequence of X is a string of the form
#x_i_1 x_i_2.x_i_k ,where 1 < i_1< . < i_k < n.
#A string is palindromic if it is equal to its
#own reverse (i.e. the string is the same whether
#read backwards or
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
#Your task is twofold:
#1. Implement the polycomp(A,B) procedure below so
# that it returns the composition of polynomials A and B.
#2. Explain why your algorithm is O(n^3 log n) or
# (better still) O(n^3)
# Answer: In order to perform A(B(x) I need B,
#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
#
import numpy as np
#Suppose there is a procedure inA that decides a language A.
#Use dynamic programming (not memoization) to create an
#algorithm that decides A* while calling inA only O(n^2) times,
#where n is the length of the input string.
#This is
#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)
import pycosat
import itertools
def reduce_it(G):
" Input: an adjacency matrix G of arbitrary size represented as a list of lists.
Output: the clauses of the cnf formula output in pycosat format.
Each clause is be reprented as a list of nonzero intege
#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 ['
#Suppose we have a one-tape Turing machine M whose
#head instead of having to move just left or right
#in each computation step, can move left or right
#or stay put. We called these stay-put machines
#in the lesson.
#It is possible to create a new st