Discrete Structures Assignments
Discrete Structures Assignments
Assignment#1
1. Which of these sentences are propositions? What are the truth values of those that are
propositions?
a) Boston is the capital of Massachusetts.
b) Miami is the capital of Florida.
c) 2 + 3 = 5.
d) 5 + 7 = 10.
e) x + 2 = 11.
f) Answer this question.
a) ¬p
b) p∨q
c) p→q
d) p∧q
e) p↔q
f) ¬p →¬q
g) ¬p ∧¬q
h) ¬p ∨ (p ∧ q)
p : It is below freezing.
q : It is snowing.
Write these propositions using p and q and logical connectives (including negations).
a) p→q
b) ¬q ↔ r
c) q →¬r
d) p∨q∨r
e) (p →¬r) ∨ (q →¬r)
f) (p ∧ q) ∨ (¬q ∧ r)
a) 2 + 2 = 4 if and only if 1 + 1 = 2.
b) 1 + 1 = 2 if and only if 2 + 3 = 4.
a) If 1 + 1 = 2, then 2 + 2 = 5.
b) If 1 + 1 = 3, then 2 + 2 = 4.
c) If 1 + 1 = 3, then 2 + 2 = 5.
8. How many rows appear in a truth table for each of these compound propositions?
a) p →¬p
b) (p ∨¬r) ∧ (q ∨¬s)
d) (p ∧ r ∧ t) ↔(q ∧ t)
a) p ∧¬p
b) p ∨¬p
c) (p ∨¬q) → q
d) (p ∨ q) → (p ∧ q)
e) (p → q) ↔ (¬q →¬p)
f ) (p → q) → (q → p)
a) p ∧ T ≡ p
b) p ∨ F ≡ p
c) p ∧ F ≡F
d) p ∨ T ≡ T
e) p ∨ p ≡ p
f)p∧p≡p
¬(p ∧ q) ≡ ¬p ∨¬q
12. Use De Morgan’s laws to find the negation of each of the following statements.
13. Show that each of these conditional statements is a tautology by using truth tables.
a) (p ∧ q) → p
b) p → (p ∨ q)
c) ¬p → (p → q)
d) (p ∧ q) → (p → q)
20. The dual of a compound proposition that contains only the logical operators ∨, ∧, and ¬
is the compound proposition obtained by replacing each ∨ by ∧, each ∧ by ∨, each T by
F, and each F by T. The dual of s is denoted by s. Find the dual of each of these
compound propositions.
a) p ∨¬q
b) p ∧ (q ∨ (r ∧ T))
c) (p ∧¬q) ∨ (q ∧ F)
c) (p ↔ q) ∧ (¬p ↔ q)
Course Title: Discrete Structures
Course Code: CS201
Assignment#2
1. Let P(x) denote the statement “x ≤ 4.” What are these truth values?
a) P(0)
b) P(4)
c) P(6)
2. Let P(x) be the statement “the word x contains the letter a.” What are these truth values?
a) P(orange)
b) P(lemon)
c) P(true)
d) P(false)
3. Let P(x) be the statement “x spends more than five hours every weekday in class,” where the
domain for x consists of all students. Express each of these quantifications in English.
a) ∃xP(x)
b) ∀xP(x)
c) ∃x ¬P(x)
d) ∀x ¬P(x)
4. Let P(x) be the statement “x can speak Russian” and let Q(x) be the statement “x knows the
computer language C++.” Express each of these sentences in terms of P(x), Q(x), quantifiers,
and logical connectives. The domain for quantifiers consists of all students at your school.
a) There is a student at your school who can speak Russian and who knows C++.
b) There is a student at your school who can speak Russian but who doesn’t know C++.
c) Every student at your school either can speak Russian or knows C++.
5. Let P(x) be the statement “x = x2.” If the domain consists of the integers, what are these truth
values?
a) P(0)
b) P(1)
c) P(2)
d) P(−1)
e) ∃xP(x)
f ) ∀xP(x)
6. Determine the truth value of each of these statements if the domain consists of all integers.
a) ∀n(n + 1 > n)
b) ∃n(2n = 3n)
c) ∃n(n = −n)
d) ∀n(3n ≤ 4n)
7. Determine the truth value of each of these statements if the domain consists of all real
numbers.
a) ∃x(x3 = −1)
c) ∀x((−x)2 = x2)
d) ∀x(2x > x)
8. Suppose that the domain of the propositional function P(x) consists of the integers 0, 1, 2, 3,
and 4. Write out each of these propositions using disjunctions, conjunctions, and
negations.
a) ∃xP(x)
b) ∀xP(x)
c) ∃x¬P(x)
d) ∀x¬P(x)
e) ¬∃xP(x)
f ) ¬∀xP(x)
9. For each of these statements find a domain for which the statement is true and a domain for
which the statement is false.
10. Suppose the domain of the propositional function P(x, y) consists of pairs x and y, where x is
1, 2, or 3 and y is 1, 2, or 3. Write out these propositions using disjunctions and
conjunctions.
a) ∃x P(x, 3)
b) ∀y P(1, y)
c) ∃y¬P(2, y)
d) ∀x ¬P(x, 2)
a) ∀yQ(0, y, 0)
b) ∃xQ(x, 1, 1)
c) ∃z¬Q(0, 0, z)
d) ∃x¬Q(x, 0, 1)
12. Determine whether ∀x(P(x) → Q(x)) and ∀xP(x) → ∀xQ(x) are logically equivalent. Justify your
answer.
13. Translate these statements into English, where the domain for each variable consists of all
real numbers.
a) ∀x∃y(x < y)
b) ∀x∀y(((x ≥ 0) ∧ (y ≥ 0)) → (xy ≥ 0))
c) ∀x∀y∃z(xy = z)
14. Let Q(x, y) be the statement “x has sent an e-mail message to y,” where the domain for both x
and y consists of all students in your class. Express each of these quantifications in English.
a) ∃x∃yQ(x, y)
b) ∃x∀yQ(x, y)
c) ∀x∃yQ(x, y)
d) ∃y∀xQ(x, y)
e) ∀y∃xQ(x, y)
f ) ∀x∀yQ(x, y)
15. Let S(x) be the predicate “x is a student,” F(x) the predicate “x is a faculty member,” and A(x,
y) the predicate “x has asked y a question,” where the domain consists of all people
associated with your school. Use quantifiers to express each of these statements.
c) Every faculty member has either asked Professor Miller a question or been asked a
question by Professor Miller.
e) There is a faculty member who has never been asked a question by a student.
g) There is a faculty member who has asked every other faculty member a question.
16. Translate each of these nested quantifications into an English statement that expresses a
mathematical fact. The domain in each case consists of all real numbers.
a) ∃x∀y(x + y = y)
17. Let Q(x, y) be the statement “x + y = x − y.” If the domain for both variables consists of all
integers, what are the truth values?
a) Q(1, 1)
b) Q(2, 0)
c) ∀yQ(1, y)
d) ∃xQ(x, 2)
e) ∃x∃yQ(x, y)
f) ∀x∃yQ(x, y)
g) ∃y∀xQ(x, y)
h) ∀y∃xQ(x, y)
i) ∀x∀yQ(x, y)
19. For each of these arguments determine whether the argument is correct or incorrect and
explain why.
a) All students in this class understand logic. Xavier is a student in this class. Therefore,
Xavier understands logic.
c) All parrots like fruit. Mypet bird is not a parrot. Therefore, my pet bird does not like
fruit.
d) Everyone who eats granola every day is healthy. Linda is not healthy. Therefore, Linda
does not eat granola every day.
20. Give the converse, the contrapositive, and the inverse of these conditional statements.
b) If |x| = x, then x ≥ 0.
21. Show that these statements are inconsistent: “If Sergei takes the job offer then he will get a
signing bonus.” “If Sergei takes the job offer, then he will receive a higher salary.” “If Sergei
gets a signing bonus, then he will not receive a higher salary.” “Sergei takes the job offer.”
22. Use direct proof to show that the sum of two odd integers is even.
23. Show that the square of an even number is an even number using a direct proof.
24. Use direct proof to show that the product of two odd numbers is odd.
25. Show that if n is an integer and n3 + 5 is odd, then n is even using
a) a proof by contraposition.
b) a proof by contradiction.
Course Title: Discrete Structures
Course Code: CS201
Assignment#3
a) {0, 3, 6, 9, 12}
b) {−3,−2,−1, 0, 1, 2, 3}
c) {m, n, o, p}
4. Suppose that A = {2, 4, 6}, B = {2, 6}, C = {4, 6}, and D = {4, 6, 8}. Determine which of these
sets are subsets of which other of these sets.
7. Find the power set of each of these sets, where a and b are distinct elements.
a) {a}
b) {a, b}
b) B × A.
9. Let A = {a, b, c}, B = {x, y}, and C = {0, 1}. Find
a) A × B × C.
b) C × B × A.
c) B × B × B.
10. Let A be the set of students who live within one mile of school and let B be the set of
students who walk to classes. Describe the students in each of these sets.
a) A ∩ B
b) A ∪ B
c) A – B
d) B – A
b) A ∩ B.
c) A − B.
d) B − A.
b) (A ∩ B) ∪ (A ∩ B) = A.
14. Let A = {0, 2, 4, 6, 8, 10}, B = {0, 1, 2, 3, 4, 5, 6}, and C = {4, 5, 6, 7, 8, 9, 10}. Find
a) A ∩ B ∩ C.
b) A ∪ B ∪ C.
c) (A ∪ B) ∩ C.
d) (A ∩ B) ∪ C.
16. Find the domain and range of these functions. Note that in each case, to find the
domain, determine the set of elements assigned values by the function.
a) the function that assigns to each nonnegative integer its last digit
b) the function that assigns the next largest integer to a positive integer
c) the function that assigns to a bit string the number of one bits in the string
d) the function that assigns to a bit string the number of bits in the string
19. Determine whether each of these functions from {a, b, c, d} to itself is one-to-one.
a) f (a) = b, f (b) = a, f (c) = c, f (d) = d
b) f (a) = b, f (b) = b, f (c) = d, f (d) = c
c) f (a) = d, f (b) = b, f (c) = c, f (d) = d
20. Determine whether each of these functions from {a, b, c, d} to itself is onto.
a) f (a) = b, f (b) = a, f (c) = c, f (d) = d
b) f (a) = b, f (b) = b, f (c) = d, f (d) = c
c) f (a) = d, f (b) = b, f (c) = c, f (d) = d
25. Show that the function f (x) = |x| from the set of real numbers to the set of nonnegative
real numbers is not invertible, but if the domain is restricted to the set of nonnegative
real numbers, the resulting function is invertible.
27. Find f ◦ g and g ◦ f , where f (x) = x2 + 1 and g(x) = x + 2, are functions from R to R.
28. Show that the function f (x) = ax + b from R to R is invertible, where a and b are constants,
with a ≠ 0, and find the inverse of f.
Course Title: Discrete Structures
Course Code: CS201
Assignment#4
a) 68
b) 84
c) 357
d) 1001
2. Show that if a, b, c, and d are integers, where a ≠ 0, such that a | c and b | d, then ab | cd.
a) 19 is divided by 7?
e) 0 is divided by 19?
f ) 3 is divided by 5?
g) −1 is divided by 3?
h) 4 is divided by 1?
4. Suppose that a and b are integers, a ≡ 4 (mod 13), and b ≡ 9 (mod 13). Find the integer c with 0
≤ c ≤ 12 such that
a) c ≡ 9a (mod 13).
c) c ≡ a + b (mod 13).
5. Let m be a positive integer. Show that a ≡ b (mod m) if a mod m = b mod m.
a) −17 mod 2
b) 144 mod 7
c) −101 mod 13
d) 199 mod 19
a) a = −111, m = 99.
b) a = −9999, m = 101.
c) a = 10299, m = 999.
d) a = 123456, m = 1001.
a) 21
b) 29
c) 71
d) 97
e) 111
f ) 143
11. Find the prime factorization of each of these integers.
a) 88
b) 126
c) 729
d) 1001
e) 1111
f ) 909,090
12. What are the greatest common divisors of these pairs of integers?
a) 22 ・ 33 ・ 55, 25 ・ 33 ・ 52
13. What are the least common multiple of these pairs of integers?
a) 22 ・ 33 ・ 55, 25 ・ 33 ・ 52
14. Find gcd(1000, 625) and lcm(1000, 625) and verify that gcd(1000, 625) ・ lcm(1000, 625) = 1000
・ 625.
a) gcd(1, 5).
b) gcd(100, 101).
c) gcd(123, 277).
d) gcd(1529, 14039).
e) gcd(1529, 14038).
f ) gcd(11111, 111111).
Course Title: Discrete Structures
Course Code: CS201
Assignment#5
1. Let P(n) be the statement that 12 + 22 +· · ·+n2 = n(n + 1)(2n + 1)/6 for the positive integer n.
a) What is the statement P(1)?
b) Show that P(1) is true, completing the basis step of the proof.
c) What is the inductive hypothesis?
d) What do you need to prove in the inductive step?
e) Complete the inductive step, identifying where you use the inductive hypothesis
f) Explain why these steps show that this formula is true whenever n is a positive
integer.
2. Let P(n) be the statement that 13 + 23 +· · ·+n3 = (n(n + 1)/2)2 for the positive integer n.
a) What is the statement P(1)?
b) Show that P(1) is true, completing the basis step of the proof.
c) What is the inductive hypothesis?
d) What do you need to prove in the inductive step?
e) Complete the inductive step, identifying where you use the inductive hypothesis.
f) Explain why these steps show that this formula is true whenever n is a positive
integer.
7. a) Find a formula for the sum of the first n even positive integers.
b) Prove the formula that you conjectured in part (a).
8. Prove that for every positive integer n, 1 · 2 + 2 · 3+· · ·+n(n + 1) = n(n + 1)(n + 2)/3.
9. Let P(n) be the statement that n! < nn, where n is an integer greater than 1.
a) What is the statement P(2)?
b) Show that P(2) is true, completing the basis step of the proof.
c) What is the inductive hypothesis?
d) What do you need to prove in the inductive step?
e) Complete the inductive step.
10. Prove that 2 divides n2 + n whenever n is a positive integer.
11. Let P(n) be the statement that a postage of n cents can be formed using just 3-cent stamps
and 5-cent stamps. The parts of this exercise outline a strong induction proof that P(n) is
true for n ≥ 8.
a) Show that the statements P(8), P(9), and P(10) are true, completing the basis step of the
proof.
b) What is the inductive hypothesis of the proof?
c) What do you need to prove in the inductive step?
d) Complete the inductive step for k ≥ 10.
e) Explain why these steps show that this statement is true whenever n ≥ 8.
12. Let P(n) be the statement that a postage of n cents can be formed using just 4-cent stamps
and 7-cent stamps. The parts of this exercise outline a strong induction proof that P(n) is
true for n ≥ 18.
a) Show statements P(18), P(19), P(20), and P(21) are true, completing the basis step of the
proof.
b) What is the inductive hypothesis of the proof?
c) What do you need to prove in the inductive step?
d) Complete the inductive step for k ≥ 21.
e) Explain why these steps show that this statement is true whenever n ≥ 18.
Course Title: Discrete Structures
Course Code: CS201
Assignment#6
1. Give a recursive algorithm for finding the sum of the first n positive integers.
2. Give a recursive algorithm for finding the sum of the first n odd positive integers.
3. Give a recursive algorithm for finding the maximum of a finite set of integers, making use of
the fact that the maximum of n integers is the larger of the last integer in the list and the
maximum of the first n − 1 integers in the list.
4. Devise a recursive algorithm for computing the greatest common divisor of two nonnegative
integers a and b with a < b using the fact that gcd(a, b) = gcd(a, b − a).
5. Devise a recursive algorithm to find the nth term of the sequence defined by a 0 = 1, a1 = 2,
and an = an−1· an−2, for n = 2, 3, 4, . . . .
6. Devise a recursive algorithm to find the nth term of the sequence defined by a 0 = 1, a1 = 2, a2
= 3, and an = an−1 + an−2 + an−3, for n = 3, 4, 5, . . . .
Course Title: Discrete Structures
Course Code: CS201
Assignment#7
1. List the ordered pairs in the relation R from A = {0, 1, 2, 3, 4} to B = {0, 1, 2, 3}, where (a, b)
∈ R if and only if
a) a = b.
b) a + b = 4.
c) a > b.
d) a | b.
e) gcd(a, b) = 1.
2. List all the ordered pairs in the relation R = {(a, b) | a divides b} on the set {1, 2, 3, 4, 5, 6}.
3. For each of these relations on the set {1, 2, 3, 4}, decide whether it is reflexive, whether it
is symmetric, whether it is antisymmetric, and whether it is transitive.
a) {(2, 2), (2, 3), (2, 4), (3, 2), (3, 3), (3, 4)}
b) {(1, 1), (1, 2), (2, 1), (2, 2), (3, 3), (4, 4)}
c) {(2, 4), (4, 2)}
d) {(1, 2), (2, 3), (3, 4)}
e) {(1, 1), (2, 2), (3, 3), (4, 4)}
f) {(1, 3), (1, 4), (2, 3), (2, 4), (3, 1), (3, 4)}
4. Determine whether the relation R on the set of all people is reflexive, symmetric,
antisymmetric, and/or transitive, where (a, b) ∈ R if and only if
a) a is taller than b.
b) a and b were born on the same day.
c) a has the same first name as b.
5. Determine whether the relation R on the set of all Web pages is reflexive, symmetric,
antisymmetric, and/or transitive, where (a, b) ∈ R if and only if
a) everyone who has visited Web page a has also visited Web page b.
b) there are no common links found on both Web page a and Web page b.
c) there is at least one common link on Web page a and Web page b.
d) there is a Web page that includes links to both Web page a and Web page b.
6. Determine whether the relation R on the set of all real numbers is reflexive, symmetric,
antisymmetric, and/or transitive, where (x, y) ∈ R if and only if
a) x + y = 0.
b) x = ±y.
c) x − y is a rational number.
d) x = 2y.
e) xy ≥ 0.
f) xy = 0.
g) x = 1.
h) x = 1 or y = 1.
7. Represent each of these relations on {1, 2, 3} with a matrix (with the elements of this set
listed in increasing order).
a) {(1, 1), (1, 2), (1, 3)}
b) {(1, 2), (2, 1), (2, 2), (3, 3)}
c) {(1, 1), (1, 2), (1, 3), (2, 2), (2, 3), (3, 3)}
d) {(1, 3), (3, 1)
8. Draw the directed graph that represents the relation {(a, a), (a, b), (b, c), (c, b), (c, d), (d,
a), (d, b)}.
10. Which of these relations on the set of all people are equivalence relations? Determine
the properties of an equivalence relation that the others lack.
a) {(a, b) | a and b are the same age}
b) {(a, b) | a and b have met}
c) {(a, b) | a and b speak a common language}
11. Let R be the relation on the set of ordered pairs of positive integers such that ((a, b), (c,
d)) ∈ R if and only if a + d = b + c. Show that R is an equivalence relation.
12. Let R be the relation on the set of ordered pairs of positive integers such that ((a, b), (c,
d)) ∈ R if and only if ad = bc. Show that R is an equivalence relation.
13. determine whether the relation with the directed graph shown is an equivalence
relation.
14. Determine whether the relations represented by these zero–one matrices are
equivalence relations.
Course Title: Discrete Structures
Course Code: CS201
Assignment#8
1. determine whether the graph shown has directed or undirected edges, whether it has
multiple edges, and whether it has one or more loops.
2. Let G be an undirected graph with a loop at every vertex. Show that the relation R on the set
of vertices of G such that uRv if and only if there is an edge associated to {u, v} is a
symmetric, reflexive relation on G.
3. Construct the call graph for a set of seven telephone numbers 555-0011, 555-1221, 555-
1333, 555-8888, 555-2222, 555-0091, and 555-1200 if there were three calls from 555-0011
to 555-8888 and two calls from 555-8888 to 555-0011, two calls from 555-2222 to 555-0091,
two calls from 555-1221 to each of the other numbers, and one call from 555-1333 to each
of 555-0011, 555-1221, and 555-1200.
4. For each course at a university, there may be one or more other courses that are its
prerequisites. How can a graph be used to model these courses, and which courses are
prerequisites for which courses? Should edges be directed or undirected? Looking at the
graph model, how can we find courses that do not have any prerequisites and how can we
find courses that are not the prerequisite for any other courses?
5. Find the number of vertices, the number of edges, and the degree of each vertex in the given
undirected graph. Find the sum of the degrees of the vertices of each graph and verify that it
equals twice the number of edges in the graph.
6. Determine the number of vertices and edges and find the in-degree and out-degree of each
vertex for the given directed multigraph. Determine the sum of the in-degrees of the vertices
and the sum of the out-degrees of the vertices directly. Show that they are both equal to the
number of edges in the graph.
7. Use an adjacency list to represent the each of the given graphs. Represent the each of the
given graphs with an adjacency matrix.
Assignment#9
4. Explain how a tree can be used to represent the table of contents of a book organized
into chapters, where each chapter is organized into sections, and each section is
organized into subsections.
5. Build a binary search tree for the words: banana, peach, apple, pear, coconut, mango,
and papaya using alphabetical order. How many comparisons are needed to locate or to
add each of these words in the search tree, starting fresh each time? a) ear b) banana c)
kumquat d) orange
6. Build a binary search tree for the words oenology, phrenology, campanology,
ornithology, ichthyology, limnology, alchemy, and astrology using alphabetical order.
How many comparisons are needed to locate or to add each of the words in the search
tree, starting fresh each time? a) palmistry b) etymology c) paleontology d) glaciology
7. Using alphabetical order, construct a binary search tree for the words in the sentence
“The quick brown fox jumps over the lazy dog.”
8. What are the codes for a, e, i, k, o, p, and u if the coding scheme is represented by this
tree?
9. Use Huffman coding to encode these symbols with given frequencies: a: 0.20, b: 0.10, c:
0.15, d: 0.25, e: 0.30. What is the average number of bits required to encode a
character?
10. Use Huffman coding to encode these symbols with given frequencies: A: 0.10, B: 0.25,
C: 0.05, D: 0.15, E: 0.30, F: 0.07, G: 0.08. What is the average number of bits required to
encode a symbol?
11. Construct a Huffman code for the letters of the English alphabet where the frequencies
of letters in typical English text are as shown in this table.
12. Determine the order in which a preorder traversal visits the vertices of the given ordered
rooted tree. In which order are the vertices of the ordered rooted tree visited using an
inorder traversal? In which order are the vertices of the ordered rooted tree visited using
an postorder traversal?