







Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!








From Chapter 1
p q r
F F F T T T F F F F F T T F T F F F F T F F T T F F F F T T F F F T F T T F F T T T F T T T F T T F T F F F T T F F T T F T T T T T F F F T F T
Here’s one: This also works but is longer:
(definition of ) (DeMorgan’s law) (defn. of again) (distributive law) (standard contradiction) (or with false) (associative law) (std. contradiction) (and with false) (not false)
¬( r →¬ q )∨( p ∧¬ r )
¬ q ¬ r r → ¬ q ¬( r →¬ q ) p ∧ ¬ r ¬( r →¬ q )∨( p ∧¬ r )
( p ⊕ q ⊕ r ) ∧¬( p ∧ q ∧ r ) ( p ∧ ¬ q ∧¬ r ) ∨ ( ¬ p ∧ q ∧¬ r ) ∨( ¬ p ∧ ¬ q ∧ r )
( q ∧( p →¬ q )) →¬ p
( q ∧( p →¬ q )) → ¬ p ⇔ ¬( q ∧( p →¬ q ))∨ ¬ p → ⇔ ¬( ( q ∧( p →¬ q )) ∧ p ) ⇔ ¬( ( q ∧( ¬ p ∨¬ q )) ∧ p ) → ⇔ ¬( ( ( q ∧¬ p ) ∨( q ∧¬ q )) ∧ p ) ⇔ ¬( ( ( q ∧¬ p ) ∨ F ) ∧ p ) ⇔ ¬( ( q ∧¬ p ) ∧ p ) ⇔ ¬( q ∧( ¬ p ∧ p )) ⇔ ¬( q ∧ F ) ⇔ ¬ F ⇔ T
Original statement: p -> q “If you study hard, then you will excel.”
(Remember that of these three, it is the contrapositive and only the contrapositive that is logically equivalent to the original implication.)
lowing predicate logic statements in a universe of discourse of the integers: (a) (b)
(c) (d) (e) (f) (g) .
(a) true - there is something that divides something (e.g. 1 divides 1) (b) false - not everything divides everything (e.g. 2 does not divide 3) (c) true - everything divides itself (e.g., 3 divides 3) (d) true - there is something (namely 1) that divides everything (e) true - for everything, there is something it divides (e.g., itself) (f) true - there is something that everything divides (namely y=0). For any integer x, x|y, because there is an integer b (0) such that xb=y. (See defn 1 on p. 113) (g) true - for everything, there is something that divides it (e.g., 1)
(a) (b) (c) (d) (e)
¬ q →¬ p ¬( p → q )⇔ ¬( ¬ p ∨ q )⇔ p ∧¬ q
∃ x ∃ y P(x,y) ∀ x ∀ y P x y ( , ) ∀ x P x x ( , ) ∃ x ∀ y P x y ( , ) ∀ x ∃ y P x y ( , ) ∃ y ∀ x P x y ( , ) ∀ y ∃ x P x y ( , )
∀ x ( A x ( ) ∨ B x ( )) → F x ( ) ∀ x F x ( ) → B x ( ) ∀ x ∃ y T x y ( , ) ∃ x A x ( ) ∧ ¬∃ y T x y ( , ) ∧ M y ( ) ∀ x ( A x ( ) ∧ F x ( )) → ∃ y T x y ( , ) ∧ U y ( )
This is a telescoping sum. All the terms cancel out except for 1/1 in the first term, and 1/(n+1) in the last term. So the sum is 1 + 1/(n+1) = (n+2)/(n+1).
3n^2 +8n+7 3n^2 +8n^2 +7n^2 if n> = 18 n^2
So f(n) < 18 n^2 if n>1. So with k=1 and c=18, f(n)<c n^2 , so by definition f(n) is O(n^2 ).
(x+2) is order x. log(x^2 +1) is log of order x^2 , which is order 2 log x which is order log x. Multiplying the orders, the first term is order x log x. The second term is similarly order log x, and since this is lower than x log x the second term drops out, leaving just order (x log x) overall.
From Chapter 2
procedure findlasteven (a1, a2, ..., an : integers) i := n while (i > 0) { if (2|ai) then return i i := i - 1 } return 0
On each iteration, the size of the range of indices being searched is cut roughly in
i
i + 1
i = 1
n
∀ n>k
Θ ( x log x )
half. After n halvings, the size is cut by about 2n. If the initial size is about 2n^ then after n iterations the size will be about 1 (and from there the algorithm takes only constant time). Therefore, the number of iterations is about log 2 of the initial number of elements, and each iteration takes constant time, so the total time is order log 2 n. The base does not make a difference to the order so we can express this as just order (log n).
procedure perm (n, k: integers) prod := 1 for i := n-k+1 to n prod := prod i return prod
(a) order k (the first loop has k iterations) (b) order n (since k is at most n)
(a) 1024 = 2^10 (b) 1025 = 2541 = 5^2 (c) 510,510 = 5101001 = 10511001 = 25511001 = 23571113* Part (c) is rather difficult without a calculator and we wouldn’t give one that hard on a real exam.
30 = 235, so we are listing all integers<50 that don’t have any of these factors. Eliminate all even numbers, numbers ending in 5, and numbers divisible by 3, and we get: 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 49
A real exam question like this would probably be a bit shorter.
(a) 12! because 12!|20! (b) 20! (c) 2^89
0, because 50|50!.
This is false as stated because for n=2, n^2 -1 = 3 which is prime. However, if we had said n>2, it would be true because (n^2 -1) can be factored into (n+1)(n-1). For n>2, (n-1)>1, so the number n^2 -1 has a factor other than itself and 1 and so is composite.
“Proof: We want to prove that for all integers , the number 2 n +1 is prime. Let n be any inte- ger greater than or equal to 1, for example, n =1, n =2, or n =3. If n =1, then 2 n +1=3, which is prime. If n =2, then 2 n +1=5, which is prime. If n =3, then 2 n +1=7, which is prime. We can see
from these examples that whenever , the number 2 n +1 is always prime.” Explain what is wrong with this “proof.” It’s not enough just to show that the “theorem” is false. You must iden- tify the general flaw with the overall type of reasoning that is used in this “proof,” and explain why this sort of reasoning is logically invalid.
The flaw is that it tries to prove a universal statement merely by giving a few examples for which it is true. This is never a valid procedure because it does not prove that the statement is still true for all the other examples that were not considered. In this case the flaw is obvious, since if the example n=4 were tried, 2n+1 = 9 which isn’t prime. However, sometimes the exceptions may be less obvious. So you should always stay away from this practice. It simply isn’t logically valid.
greater than or equal to the average of these numbers.
Proof by contradiction: Suppose all the numbers were less than their average x, that is, for all i, ai < x = (a 1 +...+an)/n. But the sum of n numbers, each less than x is obviously less than nx. So we have that a 1 +...+an < nx = n(a 1 +...+an)/n = a 1 +...+an, that is, we have that a 1 +...+an < a 1 +...+an, that is, the sum is less than itself, which is impossible. So the assumption that all the numbers were less than their average must be false, therefore some number must be greater than average.
n ≥ 2
n ≥ 1 2 n + 1 n ≥ 1
n ≥ 1
( 2 i – 1 ) i = 1
n
2 = n ≥ 1
n
(a) an =2 n , (b) an = 3 n - 5, (c) an =( n +1)/3, (d) an = , (e) an = , (f) an = n^2 + n
(a) a(n) = 2a(n-1), a(1)= (b) a(n) = a(n-1)+3, a(1)=- (c) a(n) = a(n-1)+1/3, a(1)=2/ (d) a(n) = a(n-1), a(1)=sqrt(2)
(e) a(n) = , a(1) =. (d) a(n) = a(n-1) + 2n, a(1) = 2
, and for all integers n, if then.
(a) f(0)=3, f(1)=12, f(2)=30, f(3)= (b) f(0)=1, f(1)=4, f(2) = 5, f(3)=
From Chapter 4
(a) 26^7 = 8,031,810,176 - more than eight billion (b) 26!/(26-7)! = 26252423222120 = 3,315,312,000 - more than three billion (c) 26^6 = 308,915,776 - three hundred million (d) 26^6 *5 = 1,544,578,880 - over a billion (e) 21^7 = 1,801,088,541 - over a billion (f) 21^6 * 7 * 5 = 3,001,814,235 - three billion
There are 11 letters so there would be 11! permutations if they were all different. But the 2!=2 orderings of the 2 C’s don’t matter, nor do the 2!=2 orderings of the 2 E’s, ditto for the 2 F’s and 2 I’s. So we get 11!/2^4 = 111098765432/222 = 111097654*3 = 2,494,800 orderings that make a difference
1 ⁄ 2 n
an – 1 22
0 ∈ S n ∈ S n + 3 ∈ S
(b) 25000*1.05n-1^ - be careful here : in year n=1, we have 1.05 to the 0! (c) about 38,783, (d) s(n) = s(n-1) * 1.02 + 1000
Use iterative approach to solve: let a=1000, b=1. s(n) = s(n-1)b + a = (s(n-2)b + a)b + a = s(n-2)b^2 + ab + a = (s(n-3)b + a)b^2 + ab + a = s(n-3)*b^3 + ab^2 + ab + a
= s(n-k)*bk^ +.
This summation has a standard formula from the text (table 2, p. 76):
s(n) = s(n-k) bk^ +
Letting n-k=1 or k=n-1, we have
s(n) = s(1) bn-1^ +
or s(10) = 39,631.
(a) an = 0.7 an -1 - 0.3 an -2 (b) an = n an -1 (c) an = 5 an -1^2 - 3 an -2 (d) an = an -1 + 1
(a) only
(a) Write its characteristic equation. (b) Find its roots and their multiplicities. (Hint: one of the roots of the characteristic equation is r=-1). (c) Write the form of general solutions to the recurrence relation.
There is a bug in the problem statement. r=-1 is not a root, and the true roots are difficult to find. I’ll be more careful on the real final. This was intended to be similar to the quiz question.
From Chapter 6
ab i
i = 0
k – 1
ab k
a b – 1
------------ b n – 1 ⋅( – 1 )
sn 25 000, 1. n – 1 ⋅ 50 000, 1. n – 1 = + ⋅( – 1 )
(a) The relation R on the numbers N={1,2,3,...} where aRb means a|b. (b) The relation R on {w,x,y,z} where R={(w,w), (w,x), (x,w), (x,x), (x,z), (y,y), (z,y), (z,z)}.
(c) The relation R on Z where aRb means |a-b|.
(a) {reflexive, antisymmetric, transitive} (b) {reflexive} (c) {reflexive, symmetric}
With the ordering -2,-1,0,1,2:
(b) symmetric, (c) antisymmetric, (d) transitive.
(a) yes (b) no (c) no (d) no
No, it is not. It is not reflexive: 22 isn’t negative. It is symmetric: If ab is negative, then so is ba. But it is not transitive: 1-1 is negative, and -12 is negative, but 12 is not negative.
a Hamilton path from a to b.
Pick verts 1 and 2. Then one Hamiltonian path from 1 to 2 is 1,5,4,3,6,