Download Fall 2009

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

System of linear equations wikipedia , lookup

Transcript
Mathematics Masters Examination
OPTION 4
Fall 2009
COMPUTER SCIENCE
2–5 PM, August 18
NOTE: Any student whose answers require clarification may be required to submit to an
oral examination.
Each of the twelve numbered questions is worth 20 points. All questions will be graded, but
your score for the examination will be the sum of your scores on your eight best questions.
Please observe the following:
• DO NOT answer two or more questions on the same sheet
(not even on both sides of the same sheet).
• DO NOT write your name on any of your answer sheets.
You will be given separate instructions on the use of these answer sheets. When you have
completed a question, place it in the large envelope provided.
Fall 09 CS
1/4
Computer Algorithms
1. Assume n is a power of 2.
a) Find the exact solution of the recurrence
n
T (n) = 2T ( ) + 2, T (2) = 1.
2
b) Give a divide-and-conquer algorithm that for an array of n distinct numbers returns the
largest and the second largest elements. The algorithm should be such that its running time
(measured in the number of comparisons) equals T (n) above. Provide a proof.
2. The following parenthesis structure is created by a run of the depth-first search on the
graph G.
vertex label
A B D D E E B C C A F G H H I J J I G F
( ( ( ) ( ) ) ( ) ) ( ( ( ) ( ( ) ) ) )
(a) Reconstruct the corresponding predecessor forest.
(b) What is the maximal number of strongly connected components in G? Explain.
(c) What are the strongly connected components of the graph whose edges are the edges of
the forest (a) and the edges considered in (d)?
(d) Assuming the following edges are in the graph G,
(i) the edge (F, A) is a back / forward / tree / cross edge;
(ii) the edge (E, C) is a back / forward / tree / cross edge;
(iii) the edge (J, F ) is a back / forward / tree / cross edge;
(circle the correct answers)
Combinatorics
3. a) Does there exist a Steiner Triple system with 49 points? If not, give a proof that it
does not exist. If it does exist, describe how you would construct it.
b) Same problem with 49 replaced by 48.
4. How many different colorings with k colors are there of the corners of a regular hexagon?
Here two colorings are considered the same if one can be obtained from the other by a
rotation or a reflection (or a combination of the two).
Fall 09 CS
2/4
Graph Theory
Remark. In these problems, a graph can have multiple edges joining two nodes and it can
have loops (edges with a single associated node).
5. A graph is said to be cubic if every node has degree three. Let G be a finite connected
cubic plane graph. Show that G must have at least one face with either two, three, four
or five edges. Give an example of a connected cubic plane graph that has no regions with
fewer than six edges.
6. Let G be a finite graph with n nodes. Let A(G) be the n×n adjacency matrix for G. That
is, A(G)i,i is the number of loops at the node i and A(G)i,j is the number of edges between
node i and node j when i 6= j. Prove that the i, j entry of A(G)k is equal to the number of
walks in G of length k from node i to node j. Suppose that A(G) is a diagonalizable matrix
over the real numbers. State and prove a formula in terms of the eigenvalues of A(G) for
the number of walks in G from node i to node j of length k. Apply your result to the graph
G with nodes 1 and 2, with one edge between 1 and 2 and a loop at 1. Find an explicit
formula for the number of walks of length k from node 1 to node 1.
Error-Correcting Codes and Cryptography
7. Given a prime number p, and a, b two numbers modulo p, with (p, ab) = 1, we define
La (b) to be any number k such that ak ≡ b mod p (provided that such a number k exists).
(a) Show that for any p, a, b, La (b) is well-defined modulo p − 1.
(b) Verify that 2 is a primitive root modulo 101. WARNING: Computing 2i for i = 1, . . . , 100
will get you ZERO. Do something more intelligent.
(c) Suppose you know that L2 (3) = 69. Calculate L2 (24).
8. (a) Show that if n = 35 is used as an RSA modulus, then always e = d.
(b) The ciphertext 5859 was obtained from the RSA using n = 11413 and e = 7467. Find
the plaintext. Note n = 101 × 113.
Fall 09 CS
3/4
Theory of Computation
9. Is the language
L = {am bn cp | m, n, p ≥ 0, m ≥ p}
context free?
10. Is the language
A = {hM i | M is a DFA such that L(M ) 6= Σ∗ }
Turing decidable? Note: Σ denotes the alphabet of M .
Numerical Analysis
11. For this problem, assume your operating system stores numbers in the form r =
±0.d1 d2 d3 × 10t , with t ∈ [−9, 9]). The di are integers in [0, 9]. Use Gaussian Elimination with a pivoting scheme which reduces loss of precision errors to solve Ax = b.


 
1
5, 000 3
1
1
4 
and
b =  5 .
A =  0.0001
4
5
2
3
12. Show that Newton’s method,
xn+1 = xn −
f (xn )
,
f 0 (xn )
converges quadratically for x0 sufficiently close to a root x∗ , if f 0 (x∗ ) 6= 0 and f (x) is twice
differentiable in a neighborhood of x∗ .
Fall 09 CS
4/4
Mathematics Masters Examination
Solutions
OPTION 4
Fall 2009
COMPUTER SCIENCE
2–5 PM, August 18
NOTE: Any student whose answers require clarification may be required to submit to an
oral examination.
Each of the twelve numbered questions is worth 20 points. All questions will be graded, but
your score for the examination will be the sum of your scores on your eight best questions.
Please observe the following:
• DO NOT answer two or more questions on the same sheet
(not even on both sides of the same sheet).
• DO NOT write your name on any of your answer sheets.
You will be given separate instructions on the use of these answer sheets. When you have
completed a question, place it in the large envelope provided.
Fall 09 CS
1/4
Computer Algorithms
1. Assume n is a power of 2.
a) Find the exact solution of the recurrence
n
T (n) = 2T ( ) + 2, T (2) = 1.
2
b) Give a divide-and-conquer algorithm that for an array of n distinct numbers returns the
largest and the second largest elements. The algorithm should be such that its running time
(measured in the number of comparisons) equals T (n) above. Provide a proof.
Solution:
a) Let n = 2i+1 , then
T (n) = 2T (2i ) + 2 = 4T (2i−1 ) + 4 + 2 = . . .
3
= 2i T (2) + 2i + 2i−1 . . . + 2 = 2i + 2i+1 − 2 = n − 2.
2
b) Divide the array in two equal parts A and B. Compute (recursively) the largest and the
second largest elements (A1 , A2 ) and (B1 , B2 ) for A and B, respectively.
If A1 > B1
then return (A1 , max(A2 , B1 ))
else return (B1 , max(B2 , A1 )).
Given an array of length n, the running time T (n) of the algorithm is the sum of its running
times for the parts (T ( n2 ) for each) and 2, since two comparisons are made in the “merge”
step.
2. The following parenthesis structure is created by a run of the depth-first search on the
graph G.
vertex label
A B D D E E B C C A F G H H I J J I G F
( ( ( ) ( ) ) ( ) ) ( ( ( ) ( ( ) ) ) )
(a) Reconstruct the corresponding predecessor forest.
(b) What is the maximal number of strongly connected components in G? Explain.
(c) What are the strongly connected components of the graph whose edges are the edges of
the forest (a) and the edges considered in (d)?
(d) Assuming the following edges are in the graph G,
Fall 09 CS
2/4
(i) the edge (F, A) is a back / forward / tree / cross edge;
(ii) the edge (E, C) is a back / forward / tree / cross edge;
(iii) the edge (J, F ) is a back / forward / tree / cross edge;
(circle the correct answers)
Solution:
(a) The edges of the forest are: AB, AC, BD, BE, F G, GH, GI, IJ.
(b) Ten: each vertex forms a strongly connected component.
(c) Seven components: A, B, C, D, E, H, F GIJ.
(d) Cross, cross, back.
Combinatorics
3. a) Does there exist a Steiner Triple system with 49 points? If not, give a proof that it
does not exist. If it does exist, describe how you would construct it.
b) Same problem with 49 replaced by 48.
Solution.
(a) Yes. There is a general construction that, given a STS with a points and one with b
points, produces one with ab points. Here we let a = b = 7 and observe that the Fano plane
is a STS with 7 points.
(b) Since 48 is not congruent to 1 or 3 modulo 6, there is no STS with 48 points.
4. How many different colorings with k colors are there of the corners of a regular hexagon?
Here two colorings are considered the same if one can be obtained from the other by a
rotation or a reflection (or a combination of the two).
Solution. In the Dihedral group, the six rotations yield
id , (123456), (135)(246), (14)(25)(36), (153)(264), (165432),
and the six reflections yield
(26)(35), (31)(46), (42)(51), (12)(36)(45), (23)(14)(56), (16)(25)(34)
We get that #(f ) = 4 for three different f , #(f ) = 3 for four different f , #(f ) = 2
for two different f , and #(f ) = 1 for two f . Together with the identity, we obtain that
(k 6 + 3k 4 + 4k 3 + 2k 2 + 2k)/12 is the number of colorings.
Fall 09 CS
3/4
Graph Theory
Remark. In these problems, a graph can have multiple edges joining two nodes and it can
have loops (edges with a single associated node).
5. A graph is said to be cubic if every node has degree three. Let G be a finite connected
cubic plane graph. Show that G must have at least one face with either two, three, four
or five edges. Give an example of a connected cubic plane graph that has no regions with
fewer than six edges.
Solution. Let e denote the number of edges of G, n denote the number of nodes of G,
and f denote the number of faces of G.. Then we have 3n = 2e by counting three edges at
each node. We also have n − e + f = 2 by Euler. Let fi denote the number of faces with i
edges. Then f = f2 + f3 + · · · and 2e = 2f2 + 3f3 + · · · . Putting these facts into Euler’s
formula, we find that 12 + f7 + 2f8 + · · · = 4f2 + 3f3 + 2f4 + f5 , from which it follows that
one of f2 , f3 , f4 , f5 is non-zero. The hexagonal tiling of the plane is a graph (infinite, cubic,
connected) such that every face has six edges.
6. Let G be a finite graph with n nodes. Let A(G) be the n×n adjacency matrix for G. That
is, A(G)i,i is the number of loops at the node i and A(G)i,j is the number of edges between
node i and node j when i 6= j. Prove that the i, j entry of A(G)k is equal to the number of
walks in G of length k from node i to node j. Suppose that A(G) is a diagonalizable matrix
over the real numbers. State and prove a formula in terms of the eigenvalues of A(G) for
the number of walks in G from node i to node j of length k. Apply your result to the graph
G with nodes 1 and 2, with one edge between 1 and 2 and a loop at 1. Find an explicit
formula for the number of walks of length k from node 1 to node 1.
Solution. Let M = A(G). Then
k
Mi,j
= Σ1≤i1 ,··· ,ik−1 ≤n Mi,i1 Mi1 ,i2 · · · Mik−1 ,j .
From this it follows that each walk of length k in G from i to j will be counted exactly
k
once in the summation for Mi,j
. If A = A(G) is diagonalizable, then there is an invertible
−1
matrix P such that P AP = D where D is a diagonal matrix with entries λ1 , · · · λn on the
diagonal. Denote this matrix by D = Diag(λ1 , · · · λn ). Then Ak = P −1 Diag(λk1 , · · · λkn )P,
and this formula for Ak allows one to write down explicit formulas for the number of walks.
For the graph G in the last part of the problem, the adjacency matrix is
µ
¶
1 1
A=
.
1 0
Fall 09 CS
4/4
√
√
The eigenvalues of this matrix are λ = (1 + 5)/2 and µ = (1 − 5)/2. From this it follows
that A is diagonalized by
µ
¶
λ µ
,
P =
1 1
with
P
−1
√
= (1/ 5)
and
µ
D=
µ
1 −µ
−1 λ
λ 0
0 µ
¶
,
¶
.
From this it follows by taking the 1 − 1 term of P −1 Dk P that the number of walks of length
k from node 1 to itself is equal to
√
(λk+1 − µk+1 )/ 5.
Error-Correcting Codes and Cryptography
7. Given a prime number p, and a, b two numbers modulo p, with (p, ab) = 1, we define
La (b) to be any number k such that ak ≡ b mod p (provided that such a number k exists).
(a) Show that for any p, a, b, La (b) is well-defined modulo p − 1.
(b) Verify that 2 is a primitive root modulo 101. WARNING: Computing 2i for i = 1, . . . , 100
will get you ZERO. Do something more intelligent.
(c) Suppose you know that L2 (3) = 69. Calculate L2 (24).
Solution.
(a) We need to check that ax+k(p−1) ≡ ax mod p for all integers x, k, or what is the same
ap−1 ≡ 1 mod p. This is the so-called Fermat’s Little Theorem.
(b) 101 − 1 = 100 has prime factors 2, 5. Since 100/2 = 50 and 100/5 = 20, we need to
check that
250 6≡ 1 mod 101;
and
220 6≡ 1 mod 101.
We have 20 = 24 + 22 amd 50 = 25 + 24 + 21 . We have
0
22 ≡ 2 mod 101;
Fall 09 CS
5/4
1
22 ≡ 4 mod 101;
2
22 ≡ 16 mod 101;
3
22 ≡ 256 ≡ 54
≡ 542 ≡ 2916 ≡ 88
25
≡ 882 ≡ 7744 ≡ 68 mod 101.
2
2
Consequently,
mod 101;
24
5
4
mod 101;
1
250 ≡ 22 .22 .22 ≡ 68 × 88 × 4 ≡ 100 mod 101.
Also,
4
2
220 ≡ 22 .22 ≡ 88 × 16 ≡ 95 mod 101.
(c) We will do everything modulo 101 − 1 = 100. We have L2 (24) ≡ L2 (23 × 3) ≡ L2 (23 ) +
L2 (3) ≡ 3 + 69 ≡ 72 mod 100.
8. (a) Show that if n = 35 is used as an RSA modulus, then always e = d.
(b) The ciphertext 5859 was obtained from the RSA using n = 11413 and e = 7467. Find
the plaintext. Note n = 101 × 113.
Solution.
(a) The statement of the problem is equivalent to saying that for all (e, φ(35)) = 1, we have
e2 ≡ 1 mod φ(35). We have φ(35) = (5 − 1)(7 − 1) = 24. Thus we need to verify that if
(e, 24) = 1, then e2 ≡ 1 mod 24. It is clear that e2 ≡ (−e)2 mod 24 for all e. Thus if we
use the set {−11, . . . , −1, 0, 1, . . . , 11, 12} as a complete set of residues modulo 24, then we
just need to check the assertion for numbers e satisfying 0 ≤ e ≤ 12. The only numbers in
this interval co-prime to 24 are 1, 5, 7, 11, and for these numbers we verify 12 ≡ 1 mod 24,
52 ≡ 1 mod 24, 72 ≡ 1 mod 24, and 112 ≡ 1 mod 24.
(b) We need to find d such that ed ≡ 1 mod φ(n), i.e. 7467d ≡ 1 mod 11200 (φ(n) =
(101 − 1)(113 − 1) = 11200). Euclidean algorithm gives
3 × 7467 − 2 × 11200 = 1
and consequently we take d = 3. We compute
58592 ≡ 34327881 ≡ 8990
Fall 09 CS
mod 11413;
6/4
58593 ≡ 8990 × 5859 ≡ 52672410 ≡ 1415 mod 11413.
Theory of Computation
9. Is the language
L = {am bn cp | m, n, p ≥ 0, m ≥ p}
context free?
Solution. Yes. It is generated by the grammar
S → ASC | B
A → a
B → Bb | ²
C → c|²
10. Is the language
A = {hM i | M is a DFA such that L(M ) 6= Σ∗ }
Turing decidable? Note: Σ denotes the alphabet of M .
Solution. Yes. A TM deciding A works as follows:
on input string w
if w is not the encoding of a DFA then reject
else let w = hM i
if ∃q 6∈ F reachable from q0 then accept else reject
Numerical Analysis
11. For this problem, assume your operating system stores numbers in the form r =
±0.d1 d2 d3 × 10t , with t ∈ [−9, 9]). The di are integers in [0, 9]. Use Gaussian Elimination with a pivoting scheme which reduces loss of precision errors to solve Ax = b.


 
1
5, 000 3
1
1
4 
A =  0.0001
and
b =  5 .
4
5
2
3
Fall 09 CS
7/4
Solution.
Without Pivoting






1
5, 000 3 1
1
1
1 5, 000
3
1 5, 000
3
 0.0001

1
4 5 → 0
0.5
4
5  →  0 0.5
4
5
4
5
2 3
0 −20, 000 −10 −1
0
0
160, 000 200, 000
This gives x3 = 1.25, x2 = 0 and x1 = −2.75.
With Pivoting



1
5, 000 3 1
4
5
 0.0001


1
4 5
1
5, 000
→ (P ivot)
4
5
2 3
0.0001
1

4
5
→ (Don0 t
P ivot)  0 5, 000
0
0



2 3
4
5
2
3
3 1  →  0 5, 000 2.5 0.25 
4 5
0
1
4
5

2
3
2.5 0.25 
4
5
This gives x3 = 1.25, x2 = −0.576 × 10−3 , and x1 = 0.124.
The difference in the residuals here is a factor of 103
12. Show that Newton’s method,
xn+1 = xn −
f (xn )
,
f 0 (xn )
converges quadratically for x0 sufficiently close to a root x∗ , if f 0 (x∗ ) 6= 0 and f (x) is twice
differentiable in a neighborhood of x∗ .
Solution.
Define the error En = |xn − x∗ |, so that
En+1
¯
¯
¯
¯
f
(x
)
n
∗
¯.
= |xn+1 − x | = ¯¯xn − x − 0
f (xn ) ¯
∗
Taylor expand f (xn ), for xn − x∗ small,
f (xn ) = f (x∗ + xn − x∗ ) = f (x∗ ) + f 0 (x∗ )(xn − x∗ ) + f 00 (ξ)/2(xn − x∗ )2
Fall 09 CS
8/4
f 0 (xn ) = f 0 (x∗ + xn − x∗ ) = f 0 (x∗ ) + f 00 (ξ)(xn − x∗ )
where ξ is some point, unspecified, between xn and x∗ . Substitute these expansions
¯
¯
0 ∗
∗
00
∗ 2¯
¯
f
(x
)(x
−
x
)
+
f
(ξ)/2(x
−
x
)
n
n
∗
¯.
En+1 = ¯¯xn − x −
¯
f 0 (x∗ ) + f 00 (ξ)(xn + x∗ )
Factor out f 0 (x∗ ),
En+1
¯
¯
f 00 (ξ)
∗
∗ 2¯
¯
(x
−
x
)
+
(x
−
x
)
n
n
0
∗
2f (x )
¯
¯
= ¯xn − x∗ −
¯.
f 00 (ξ)
∗
¯
¯
1 + 0 ∗ (xn + x )
f (x )
Use the geometric series formula
1
= 1 + r + r2 + ....
1−r
yielding
En+1
¯
¶µ
¶¯
µ
00
00
¯
¯
f
(ξ)
f
(ξ)
∗
2
∗
∗
∗
= ¯¯xn − x − (xn − x ) + 0 ∗ (xn − x )
1 − 0 ∗ (xn + x ) + .... ¯¯ .
2f (x )
f (x )
Simplify
En+1
¯ 00
¯
¯ f (ξ)
¯
= ¯¯ 0 ∗ (xn − x∗ )2 + O((xn − x∗ )3 )¯¯
2f (x )
Which gives En+1 ≤ CEn2 (for small En ), quadratic convergence.
Fall 09 CS
9/4