HW 6 SP13 Sol

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

MATH CSE20 Homework 6 - Solutions Due May 31, 2013

Assigned reading: 3.4, 2.6 (1) Suppose a1 , a2 , . . . is a sequence of integers dened recursively by a1 a2 ak 1 3 ak2 2ak1 1.

for integers k

Prove that an is odd for all integers n

Solution. Recall the denition of odd integers: an integer m Z is odd if and only if 2c 1. We proceed by strong induction on there is some integer c Z such that m n 1. Base step We will prove that a1 and a2 are both odd (two base steps) By denition of the sequence, a1 1 2 0 1. Since 0 Z, a1 is odd. By denition of the sequence, a2 3 2 1 1. Since 1 Z, a2 is odd. Induction step Let n 1. Assume that for all 1 k n, ak is odd. WTS that an1 is odd. If n 1 2, then were done by the base step. Otherwise, n 1 3 and both n, n 1 1. In this case, by denition of the sequence, an1 an an1 . Applying the induction assumption to n, n 1, we get that an, an1 are 2c 1 and both odd. That is, there are integers c, d such that an an1 2d 1. Calculating: an1 an 2an1

Since the integers are closed under multiplication and addition, c 2d 1


Z is our witness that an1 is odd, as required for the induction. 1, an is odd. QED

2 c 1 2 2 d 1

2c 1 4d 2

2c 2d 1 1.

We conclude that for all integers n


a1 a2 ak Prove that an 1 3 ak2 ak1
4

(2) Suppose a1 , a2 , . . . is a sequence of integers dened recursively by

7 n

for integers k 1.

for all integers n

Solution. We proceed by strong induction on n 1. 7 2 Base step We will prove that a1 7 and a2 (two base steps). 4 4 1 3 1 a1 . By denition of the sequence, a1 1. Rewriting, 7 4 4 7 2 49 1 3 16 3 By denition of the sequence, a2 3. Rewriting, 4 16

a2 .

Induction step Let n

1. 7 k . Assume that for all 1 k n, ak 4 7 n1 WTS that an1 . 4 If n 1 2, then were done by the base step. Otherwise, n 1 3 and both n, n 1 1. In this case, by denition of the sequence, an1 an an1 . Applying the induction assumption to n, n 1, we get that an 7 n1 an1 . 4 Calculating:
n

7 n
4

and

an1

an an1

n1

7 4 7 4

n1

7 4

n1

49 16

n1 2

7 4

7 4

n1

7 4

7 4

n1

7 4

11 4

n1

7 4

44 16

7 4

We conclude that for all integers n

1, an

7 n
4

. QED

(3) Find the mistake in the following proof that purports to show that every nonnegative integer power of every nonzero real number is 1. Proof: Let r be any nonzero real number and let the property P n be the statement that r n 1. Base step: WTS that P 0 holds. The property is true for n 0 because r 0 1 by denition of the zeroth power. Induction step: Let n 0 be an integer. Assume that P k holds for all 0 k n. WTS that P n 1 holds, that is, that r n1 1. We calculate: r n1 r n1n1n2 r n1 r n1 r n 2 11 1 1. because n 1 n 1 n 2 by laws of exponents by induction assumption n1

Therefore, the induction is complete. We conclude that for any nonzero real r and any nonnegative integer n, r n 1. QED

Solution: The mistake is in the application of the induction assumption to the induction step when n 1. In this case, n 2 is not a nonnegative integer (it is 1), and hence the induction assumption does not apply to the power r n2. (4) (a) Given any positive integer n, describe a connected graph with n edges such that the removal of just one edge disconnects the graph.

(b) Given any positive integer n, describe a connected graph with n edges that cannot be disconnected by the removal of any single edge. Solution: Let n be a positive integer. (a) Consider the straight line graph with n 1 vertices and n edges which has the form: ... vn1 v1 v2 v3 vn Another example is a star graph with n 1 vertices and n edges which has the form: . v3 . .

v2

vn1

v1

vn

Each of these is a template for a connected graph with the property that removing any edge disconnects the graph. (b) Consider a simple cycle graph with n vertices and n edges which has the form: . v3 . .

v2

vn

v1

vn1

This is a template for a connected graph that cannot be disconnected by the removal of a single edge. (5) A simple (undirected, loop-free) graph is called a tree if it is connected and has no cycles. (cf. Theorem 2.9) Theorem 2.10 proves that a tree with n vertices has n 1 edges. Give an example of a graph with n vertices and n 1 edges that is not a tree. Note that the two examples for part (a) of the previous questions are trees (and each has one more vertex than edges). Let n 5. Then we will give a graph with 4 edges that is not a tree.

v3 v2 v1

v5

v4

This example extends to other choices of n by either making the cycle or the path (or both) bigger, keeping the two components separate. (6) This question refers to the Reachability algorithm discussed in class on 5/24. For the denition of the algorithm, see the lecture slides on Moodle (Week 8). For an undirected graph G with n vertices, (a) What is the maximum size that the set Boundary can have during the run of the Reachability algorithm on G (with some source and target vertices)? Briey justify your answer. (b) Give an example of a graph G with 5 vertices and source and target vertices for which there is some point during the algorithm where the set Boundary has this maximum size. (c) Give an example of a graph G with 5 vertices and source and target vertices for which at no point during the algorithm does the set Boundary reach this maximum size. Solution: We recall the reachability algorithm below. Initialize labels: Ls yes; Lv ? for all other vertices. Initial boundary: Boundary s. While Boundary is not empty: Choose a vertex v Boundary . Remove v from Boundary . For all neighbours u of v in G If Lu ? then Set Lu yes Add u to Boundary . If Lt yes, return yes. Otherwise, return no. (a) The set Boundary is a subset of the set of vertices of the graph. This gives our rst n. However, when the algorithm is running on input G, s, t, bound: Boundary Ls is initialized to yes and, at the rst iteration of the while loop, s is removed from Boundary and replaced it with all of its neighbours. Since the graph is simple, there can be no self loops so s is not its own neighbour. Moreover, since Ls will never change to ?, the if-then condition if never satises for s and so s never enters the Boundary after the initialization of the algorithm. Therefore, the maximum size of the set Boundary is n 1. (b) Consider the star graph G:

v3 v2 v1

v5

v4

with source vertex v2 and target vertex any other vertex, say v1 . Then, in the rst iteration of the while loop, the algorithm processes the source vertex v2 . In doing so, it puts all the neighbours of v2 into Boundary . After this iteration, the Boundary set is v1 , v3 , v4, v5, so it has size 4 5 1. (c) Consider the totally disconnected graph G:
v3 v2 v1 v4 v5

with source vertex and target vertex and vertices, say v1 and v2 . In the rst iteration of the while loop, the Boundary changes from v1 to and never gets any new elements because the source vertex has no neighbours. The algorithm terminates at this point, since the Boundary set is empty. Thus, the largest Boundary gets while the algorithm runs with this input is 1 5 1.

You might also like