CS3500D Homework 8 Solutions
1.
15.3-1 (7 points) Both of these methods have running time
one is better.
, and therefore neither
2.
15.3-3 (8 points) Yes, this also has optimal substructure. There rea
2.6 (a)
[ Make sure that there are two as for every b, but allow them to occur in any order]
SSaSaSbS|SaSbSaS|SbSaSaS|
2.6 (b) [ Divide the complement into cases S1 through S4 ]
S0 S1 | S2 | S3 | S4
S
1.13
a) 1 *0
c)
*0101 *
l) (1*01*01*)* (0*10*10*)
1.16
a) (a*ba*)(a*ba*ba*)*
2.4
c) S
0 | 1 | SSS
e) S
1 | 1S | S1 | 1S0 | 0S1 | 10S | S10 | 01S | S01
g) R = i.e. a grammar without rules.
2.5
c) We es
1 Construct the machine M N from the given machines M, N
0
p
q
1
1
N
0
1
1
0
p
r
M
1
0
q
0
MN
1
pp
1
1
qp
0
0
rp
0
0
pq
1
1
qq
0
0
qr
1
1.4 (c) cfw_w | w = x0101y where x, y *
0,1
0
1
1
0
1
0
1
0
1.4
1 [5 pts] Give the sequence of configurations that the Turing Machine M below (see test for illustration)
enters when started on the input string 000.
1
2
3
4
5
q1000
_q200
_xq30
_x0q4
reject
2 [10 pt
1 [ Give the state diagrams of NFAs having input alphabet cfw_0, 1 that recognize the following languages.
(a) [10 pts] 0*10*10*1*
0
0
1
0,1
0
1
1
(b) [20 pts] cfw_ cfw_ w | w contains the substring 1
CS 3500 B Spring 2002 Homework 8 Problem 2-2 a. I'm not sure exactly what they had in mind here. I suppose one other thing that had better be true is that A is a permutation (that is, some reordering)
Note: I am using syntax on the lines of C here. Pseudo code as given in the text is
perfectly acceptable.
2.1-3.
l_search(A,v)cfw_
len = length[A]; for(i=0;i<len;i+)
if (A[i]=v) return i; return NIL;
2.18 b)(5 points) Assume L is a CFL. Let p the pumping lemma constant for this CFL. Choose s=0^p#0^2p#0^3p. By the pumping lemma, s can be broken into uvxyz s.t. the three conditions hold. The window
1.14) Diagram at the end. 1.17b) Suppose A2 is not regular. Then let the constant in the pumping lemma be p. Consider the string s=a2pba2pba2pb. Then obviously, s belongs to the language A2. Also, by
23.2-1: Let T be a minimum spanning tree for G. Let T' be the spanning tree given by Kruskal's algorithm and suppose that T' is distinct from T (otherwise, Kruskal generates T and we're done). Let e b
15.2-2
Please note M-C-M refers to MATRIX-CHAIN-MULTIPLICATION
M-C-M(A, s, i, j)cfw_
if( I is equal toj)
return Mi
else if ( i is equal to (j-1)
return MATRIX_MULTIPLY(Mi, Mj)
else
TEMP1 M-C-M(A, s, i
3.14 [5 pts. ea. part ] Show that the collection of decidable languages is closed under the operations
(a) union, (b) concatenation, and (c) star.
For each part, let L1 and L2 be decidable languages.
1.1-2 Rewrite the INSERTION-SORT procedure to sort into nonincreasing order instead of nondecreasing
order.
The only change occurs in line 4, where we change the second greater than sign to a less tha
CS3500D Homework 5 Solutions
1.
3.1-1 (10 points) We need to find
,
, and
such that
for all
are asymptotically nonnegative, there exists an
all
. So if
where
,
that
. Since
and
and
for
, so we let
is
CS3500D Homework 3 Solutions
4.
2.1 a. (4 points)
b. (4 points)
c. (4 points)
d. (4 points)
5.
2.3 a. (5 points) The variables are , , , ; the terminals are , , ; the start
variable is .
b. (3 points)
CS3500D Homework 1 Solutions
1.
0.1 c. (4 points) Even natural numbers:
d. (4 points) Natural numbers that are multiples of 6:
f. (4 points) The empty set,
2.
0.4 (6 points) If
is the number of elemen
CS 3500 C/D Fall 2001
Homework 8
Due 5 December 2001
1.
(15.3-1). Which is a more efficient way to determine the optimal number of multiplications
in a matrix-chain multiplication problem: enumerating
CS 3500 C/D Fall 2001
Homework 6
Due 7 November 2001
1.
(7.1-1). Using Figure 7.1 as a model, illustrate the operation of PARTITION on the array
A = 13,19,9,5,12,8,7,4,11,2,6,21 . [The caption for Fig
CS 3500 C/D Fall 2001 Homework 5 Due 31 October 2001 (Halloween) 1. (3.1-1). Let f (n) and g(n) be asymptotically nonnegative functions. Using the basic definition of -notation, prove that max( f (n),
CS3500C Fall 2001 Homework assignment #3, due October 3
1.17 a,b
1.18
1.24
2.1
2.3 a-h
2.11
2.14
Prove that a language generated by a left-linear grammar is regular.
It seems the first three w
16.1-2
PRINT-OPTIMAL-PARENS(s, i, j)
If i < j then
print (
PRINT-OPTIMAL-PARENS(s,i,s[i,j])
PRINT-OPTIMAL-PARENS(s,s[i,j]+1, j)
print )
else
print Ai
Recurrence for the running time of this algorithm
All question numbers are from the CLR textbook except for 7.4, which is from Sipser.
13.1-2 [10]
The binary search tree property states that the left child (and subsequently all descendants of the lef
8-1 [5 ea.]
(a) First, note that i is set to (p 1) and then immediately incremented before a reference, so that i p at all
points in the algorithm. Similarly, j is set to (r + 1) and then immediately