PRACTICE TEST
Chapter 1: Foundations: Sets, Logic, and Algorithms
INSTRUCTIONS: Answer each question below. Once you finish taking the test, check
the answers provided in the Answer Key at the end of this test.
For exercises 1 through 7, let A = { 1, 2, 3, 4, 5}, B = {x | x is an even positive integer},
and C = {4, 5, 6, 7, 8, 9, 10}. Let U = Z+.
1. Find A B C.
A: {1, 2, 3, ..., 10}
B: B
C: {4}
D: {4,5}
2. Find A C´.
A: {1, 2, 3, ..., 10}
B: {1, 2 ,3 ,4, 5, 11, 12, 13,...}
C: C
D: {4, 5
3. How many elements are in (A B) X C?
A: 2
B: 7
C: 14
D: 21
4. What operations on the sets A, B, and C would result in the answer {4, 5}?
A: A C
B: B C
C: A C
D: B C
©2010 Cengage Learning Asia Pte Ltd
5. What operations on the sets A, B, and C would result in the answer {6, 7, 8, 9,
10}?
A: A-B
B: B -A
C: C - A
D: B C
6. What operations on the sets A, B, and C would result in the answer {1, 3, 5, 7, 9}?
A: (A C)
B: B –(AC)
C: (A C) – B
D: (B C) – A
7. For this exercise let the universe consist of the set {1, 2, 3, . . . , 10}. Write the bit
string representation for A C.
A: 1111100000
B: 000111111
C: 00011000
D: 0000011111
For exercises 8 through 13, let
p be the statement: 6 is an even integer,
q be the statement: 9 is a prime integer, and
r be the statement: the moon is made of green cheese.
8. What is the truth value of p q ? Of q r?
A: T and F
B: F and
C: T and T
D: F and F
9. What is the truth value of p q ? Of q r?
©2010 Cengage Learning Asia Pte Ltd
A: T and F
B: F and T
C: T and T
D: F and F
10. What is the truth value of p q ? Of q r?
A: T and F
B: F and T
C: T and T
D: F and F
11. Write, in words, the negation of p.
i. 6 is not an even integer; ii. 6 is an odd integer
A: only i
B: only ii
C: both i and ii
D: neither i nor ii
12. Write, in words, the negation of q r.
A: 9 is not a prime integer and the moon is not made of green cheese.
B: 9 is not a prime integer or the moon is not made of green cheese.
C: 9 is not a prime integer and the moon is made of green cheese.
D: 9 is not a prime integer or the moon is made of green cheese.
13. Write, in words, the contrapositive of p q.
A: If 9 is not a prime integer then 6 is not an even integer.
B: If 9 is a prime integer then 6 is an even integer.
C: If 6 is not an even integer then 9 is not a prime integer.
D: If 6 is an even integer then 9 is a prime integer.
14. Is the statement p q logically equivalent to its converse?
A: no
B: yes
©2010 Cengage Learning Asia Pte Ltd
C: cannot be determined in general
D: d. depends on q
15. Is the statement p q logically equivalent to its contrapositive?
A: no
B: yes
C: cannot be determined in general
D: depends on q
16. Is the following argument valid?
If the gold is not missing then Jimmy is not left handed.
Jimmy is left handed.
Therefore the gold is missing.
A: no
B: yes
C: cannot be determined in general
D: depends on the hypothesis
17. Is the following argument valid?
If Susan runs then we win.
We win.
Therefore Susan runs.
A: no
B: yes
C: cannot be determined in general
D: depends on the conclusion
©2010 Cengage Learning Asia Pte Ltd
For exercises 18 through 22, let
P(x): x is a positive even integer,
Q(x): x is a prime.
Let the domain of discourse be the set of positive integers.
18. What is the truth value of x Q(x)?
A: true
B: false
C: cannot be determined
D: depends on x
19. What is the truth value of x P(x)?
A: true
B: false
C: cannot be determined
D: depends on x
20. What is the truth value of x (P(x) Q(x)?
A: true
B: false
C: cannot be determined
D: depends on x
21. What is the truth value of x (P(x) Q(x)?
A: true
B: false
C: cannot be determined
D: depends on x
22. What is the truth value of x (Q(x) P(x))?
A: true
B: false
C: cannot be determined
D: depends on x
©2010 Cengage Learning Asia Pte Ltd
23. Test the validity of
All dogs are sweet.
Skippy is a dog.
Therefore Skippy is sweet.
A: valid
B: not valid
C: cannot be determined
D: depends on the hypothesis
24. Find a counterexample to show the following is false.
x, y Z, | x + y | = | x | + | y |.
A: x = 2 and y = -3
B: x = -2 and y = -3
C: x = 2 and y = 3
D: a, b, and c
25. Find a counterexample to show the following is false.
n Z+, if the set S has n elements, then the power set of S has 2n elements.
A: 3
B: 2
C: 1
D: 0
26. If one wished to prove that three statements p, q, and r are equivalent, what is
the minimum number of implications that need to be proven?
A: 2
B: 3
C: 4
D: 8
27. What does the following algorithm do?
Function guess (x : integer)
Begin
©2010 Cengage Learning Asia Pte Ltd
prod := 1;
for i := 1 to x do
prod := prod * i ;
return prod;
End
A: computes x to the i power
B: computes i to the x power
C: computes i factorial
D: computes x factorial
28. In searching an arbitrary list with 1000 elements, how many comparisons would
one need to make to be certain of finding the smallest element in the list?
A: 1000
B: 999
C: 500
D: cannot be determined
©2010 Cengage Learning Asia Pte Ltd
Answers:
1. C 2. B 3. C 4. A 5. C 6. C 7. C 8. A 9. D 10. B
11. C 12. A 13. A 14. A 15. B 16. B 17. A 18. A 19. A 20. A
21. B 22. B 23. A 24. A 25. A 26. B 27. D 28. B
©2010 Cengage Learning Asia Pte Ltd