Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
125
Добавлен:
20.03.2016
Размер:
3.09 Mб
Скачать

5.Describe each of the following sets in the format fx : property of xg:

(a)A = f0, 2, 4, 6, 8, . . . g

(b)B = f 1, 2, 5, 10, 17, 26, 37, 50 , . . . g

(c)C = f1, 5, 9, 13, 17, 21, . . . g

(d)D =f 1, 1/2, 1/3, 1/4, 1/5, . . . g

(e)E = flemon, lime, 1, 3, 5, 7, . . . g

5. (a) f2j : j 2 Ng

5. (b) a1 = 1 and an = an 1 + 2n 1 for n 1 and n 2 N 5. (c) f1 + 4i : i 2 Ng

5. (d) f1=i : i 2 N and i 1g

5.(e) flemon, limeg [fj 2 N : j = 1 + 2(i 1); where i 2 Ng

7.List the subsets of each of the following sets:

(a) A = f1, 2, 3g

(b) B = f1, f2, 3gg

(c) C = ff1, 2, 3gg

7.(a) f1g, f2g, f3g, f1, 2g, f1, 3g, f2, 3g, f1, 2, 3g, ;

7.(b) f1g, ff2, 3gg, f1, f2, 3gg, ;

7.(c) ;, ff1, 2, 3gg

9.List the rst eight terms of the sequence de ned as c0 = 1; c1 = 3; and cn = cn 1 + 2cn 2 for n 2:

9.1, 3, 5, 11, 21, 43, 85, 171

Review Questions

1.Let A = f1, 2, 4, 7, 8g, B = f1, 4, 5, 7, 9g, and C = f3, 7, 8, 9g. Let U = f1, 2, 3, 4, 5, 6, 7, 8, 9, 10g. Find set expressions using these sets and the operations of union, intersection, absolute di erence, and relative di erence to represent the following sets:

(a)f2, 7, 9g

(b)f3, 5, 6, 7, 9, 10g

1. (a) (A \ B \ C) [ (A \ B \ C) [ (B \ C)

1. (b) A [ (B \ C)

3.For sets A and B, prove that A [ (B A) = A [ B:

3.

x 2 A [ (B A) , x 2 A or x 2 (B A)

,x 2 A or (x 2 B and x 62A)

,(x 2 A or x 2 B) and (x 2 A or x 62A)

,(x 2 A or x 2 B) and x 2 U

,x 2 A or x 2 B

,x 2 A [ B

5. Prove by induction that 3 + 11 + + (8n 5) = 4n2 n for n 2 N and n 1:

5. Let n0 = 1. Let

T = fn : n 1 and 3 + 11 + + (8n 5) = 4n2 ng

(Base step) For n = 1, we have 4n2 n = 4 1 = 3: Therefore, 1 2 T . (Inductive step) Assume n 2 T and prove that n + 1 2 T .

3 + 11 + + 8n 5 + 8(n + 1) 5 = 3 + 11 + + 8n 5) + 8(n + 1) 5 = 4n2 n + 8n + 3

= 4n2 + 8n + 4

= 4(n2 + 2n + 1) = (n + 1) = 4(n + 1)2 (n + 1)

Therefore, n + 1 2 T .

By the Principle of Mathematical Induction, T = N f0g.

7. Prove that for every n 2 N that n3 + n is even.

7. Let n0 = 0. Let T = fn : n 2 N and n3 + n is eveng.

(Base step) For n = 0 we have n3 + n = 0, which is even. Therefore, 0 2 T .

(Inductive step) Assume n 2 T and prove that n + 1 2 T . (n + 1)3 + (n + 1) = n3 + 3n2 + 3n + 1 + n + 1

=(n3 + n) + (3n2 + 3n + 2)

=(n3 + n) + 3n(n + 1) + 2

Since the rst term is even by the induction hypothesis and the last term is even, it remains to prove that 3n(n + 1) is even. This is obvious as with any two consecutive integers one of them is even. Also the product of an even number and an odd number is an even number so the conclusion holds. Therefore, n + 1 2 T .

By the Principle of Mathematical Induction, T = N.

9. Prove that bn = 5 2n + 1 is a closed form for the recursive relation a0 = 6; a1 = 11; and an = 3an 1 2an 2 for n 2:

9. Let n0 = 0. Let T = fn : n 2 N and 5 2n + 1 is a closed form for bng. (Base step) For n = 0; 1 the condition holds, so 0; 1 2 T :

(Inductive step) Choose n such that n is not a base case and n n0. Assume that n0; n0 + 1; : : : ; n 1 2 T and prove that n 2 T .

an = 3an 1 2an 2 def. of An)

=15 2n + 3 10 2n 1 + 2 ind. hyp.)

=20 2n 1 + 1 (simplifying the algebra)

=5 2n+1 + 1

Therefore, n 2 T .

By the Strong Form of Mathematical Induction, T = N.

11.The country of Xabob uses currency consisting of coins with values of 3 zabots and 5 zabots. If you cannot combine some number of these coins to pay a bill, the item is free. For what number of zabots are items free? Prove your answer.

11.Find a sum of 3 zabot and 5 zabot coins to total n zabots. Prove by induction that for all n such that n 10 that you can make change for n zabots. In addition show that you can make change using just 3 and 5 zabot coins for f3, 5, 6, 7g. Show you cannot make change for n = 1; 2; 4; and 7.

13.How many students are in Math 347? From the survey of all the students in the course it was found that 43 had taken Econ103, 55 had taken Soci213, 30 had taken Musi111, 8 had taken both Econ103 and Soci213, 13 had taken both Econ103 and Musi111, 15 had taken Soci213 and Musi111, and 8 had taken none of the courses. No one had taken all three courses.

13.

ECON103

 

SOCI213

 

22

8

32

0 15

13

2

MUSI111

Using Discrete Mathematics in Computer Science

1.Prove that the Largest Odd Divisor algorithm outputs the largest odd divisor of N for all integers N > 0:

1. If N is odd, the while loop is not entered and N is printed as required. If N is even, N = 2 l: The rst time through the while loop N is replaced by l: Now since l < N the algorithm works correctly for l: Since the largest odd divisor of l is the largest odd divisor of N the algorithm is correct.

3.Consider the Binary Search of Phone Directory algorithm. This algorithm looks for the page (if any) containing a name Name in a telephone book City. The portion of the algorithm used in searching for the page is called BinarySearch. Prove that the algorithm works correctly.

3. The answer will be found by an induction on the number of pages in a directory.

Base step If F irstP age = LastP age = 1 then the while loop will be executed once during which code the N ame will be found or one of F irstP age and LastP age will be decremented so that the condition F irstP age LastP age will become false or the N ame will be found in which case P ageF ound become TRUE and the loop terminates.

Inductive step Now suppose the algorithm works for all directories with 1 < k < N pages. The while loop will be entered with F irstP age LastP age and P ageF ound = F ALSE: If N ame is found on M iddleP age the value of P ageF ound is changed to TRUE and the loop will terminate with the correct answer. If N ame is not found on M iddleP age, the while loop adjusts one of the parameters F irstP age and LastP age: Now when the while loop condition is tested, the directory to be searched has fewer than N pages so that the while loop either nds the N ame or makes the condition F irstP age LastP age FALSE. Once the loop terminates, the remainder of the code prints the correct message.

5. Show by induction on n that for b 2 N, b 2,

n

X

(b 1) bi = bn+1 1

i=0

Interpret this identity in the context of number representation in the base b using the standard positional notation. Start by seeing what this means for b = 10 and n = 4:

5. This is simply the sum of the geometric series 1 + 10 + 102 + + 10n: The answer gives the largest number in base b that can be represented by n digits in that base. For b = 10 and n = 4 we get

9(1 + 10 + 102 + 103 + 104) = 99; 999

This is the largest value for that number of digits as all coe cients in an expansion are less than or equal to b 1 = 9:

7.Let X and Y be two lists sorted in nondecreasing order. Suppose that for some positive integer n; there is a combined total of n numbers in the two lists. Prove that X and Y can be merged into a single list of n numbers in nondecreasing order using at most n 1 comparisons.

7. The proof will be by induction on n: Let Z be the merged list. Let T = fn : two sorted lists of n elements can be sorted into a sorted merged list using at most n 1 comparisonsg.

(Base step) If n = 1; then either X or Y must be an empty list. But then the list Z, is obtained by making 0 = n 1 comparisons. This proves the case n = 1: Therefore, 1 2 T .

(Inductive step) Now suppose that the conclusion of the theorem holds for some positive integer n > 1: Let X and Y consist of n elements and show n 2 T . Compare x and y, the rst elements of X and Y , respectively.

CASE 1: x y : Let X0 be the list obtained by deleting x from X: Then X0 and Y are sorted lists containing a total of n elements. So by the induction hypothesis, X0 and Y can be merged into a single sorted list Z0 using at most n 1 comparisons. Form the list Z by adjoining x to Z 0 as the rst element. Then Z is in nondecreasing order because Z 0 is in nondecreasing order and x preceded all the other numbers in X and Y . Moreover, Z was formed using 1 comparison to nd that x y and at most n 1 comparisons to form list Z0. Therefore, Z was formed using at most n comparisons.

Case 2: x > y Delete y from Y to form a list Y 0: Then use the induction hypothesis as in case 1 to sort X and Y 0 into a list Z0 using at most k 1 comparisons. The list Z is then obtained by adjoining y to Z0 as the rst element. As in case 1, Z is in nondecreasing order and was formed using at most n comparisons.

Therefore, by the Principle of Mathematical Induction the result is proven.

9.Prove that, at most, n + 1 comparisons are required to determine if a particular number is in a list of 2n numbers sorted in nondecreasing order.

9. The proof will be by induction on n: Let n0 = 0: Let T = fn : at most n + 1 comparisons are required to determine if a particular number is in a list of 2n numbers sorted in nondecreasing or orderg

(Base step) For n = 0; we need to show that at most n0 + 1 = 1 comparison is required to see if a particular number m is in a list containing 20 = 1 number. Since the list contains only one number, clearly only one comparison is needed to determine if this number is m:

(Inductive step) Choose n such that n n0 and assume that n 2 T : That is, assume that at most n + 1 comparisons are needed to determine if a particular number is present in a sorted list of 2n numbers. Now prove that n + 1 2 T : Suppose that we have a list of 2n+1 numbers in

nondecreasing order. We must show that it is possible to determine if a particular number m is present in this list using at most (n +1)+1 = n +2 comparisons. To do so, we will compare m to the number p in position 2n of the list.

Case 1: m = p : In this case we need only one comparison to nd that m is in the list. Since 1 n + 2; the result is true in this case.

Case 2: m < p : Since the list is in nondecreasing order, for m to be present in the list it must lie in positions 1 through 2n. But the numbers in positions 1 through 2n are a list of 2n numbers in nondecreasing order. Hence, by the induction hypothesis we can determine if m is present in this list by using at most n + 1 comparisons. Therefore, at most 1 + (n + 1) = n + 2 comparisons are needed to determine if m is present in the original list.

Case 3: m > p : Since the list is in nondecreasing order, for m to be present in the list it must lie in positions 2n + 1 through 2n+1: In this case at most n + 2 comparisons are needed to determine if m is in the list.

Therefore, n + 1 2 T :

By the Principle of Mathematical Induction T = N.

Соседние файлы в папке Student Solutions Manual