Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
50 views

Discrete Structures Assignments

Uploaded by

yamimuto83
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views

Discrete Structures Assignments

Uploaded by

yamimuto83
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 30

Course Title: Discrete Structures

Course Code: CS201

Assignment#1

Prof. Dr. Khaled F. Hussain

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.

2. What is the negation of each of these propositions?


a) Mei has an MP3 player.
b) There is no pollution in New Jersey.
c) 2 + 1 = 3.
d) The summer in Maine is hot and sunny.

3. Let p and q be the propositions

p : I bought a lottery ticket this week.

q : I won the million dollar jackpot.

Express each of these propositions as an English sentence.

a) ¬p
b) p∨q
c) p→q
d) p∧q
e) p↔q
f) ¬p →¬q
g) ¬p ∧¬q
h) ¬p ∨ (p ∧ q)

4. Let p and q be the propositions

p : It is below freezing.

q : It is snowing.
Write these propositions using p and q and logical connectives (including negations).

a) It is below freezing and snowing.


b) It is below freezing but not snowing.
c) It is not below freezing, and it is not snowing.
d) It is either snowing or below freezing (or both).
e) If it is below freezing, it is also snowing.
f) Either it is below freezing, or it is snowing, but it is not snowing if it is below
freezing.
g) That it is below freezing is necessary and sufficient for it to be snowing.

5. Let p, q, and r be the propositions

p: You have the flu.

q: You miss the final examination.

r: You pass the course.

Express each of these propositions as an English sentence.

a) p→q
b) ¬q ↔ r
c) q →¬r
d) p∨q∨r
e) (p →¬r) ∨ (q →¬r)
f) (p ∧ q) ∨ (¬q ∧ r)

6. Determine whether these biconditionals are true or false.

a) 2 + 2 = 4 if and only if 1 + 1 = 2.

b) 1 + 1 = 2 if and only if 2 + 3 = 4.

c) 1 + 1 = 3 if and only if monkeys can fly.

d) 0 > 1 if and only if 2 > 1.

7. Determine whether each of these conditional statements is true or false.

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.

d) If monkeys can fly, then 1 + 1 = 3.

8. How many rows appear in a truth table for each of these compound propositions?
a) p →¬p

b) (p ∨¬r) ∧ (q ∨¬s)

c) q ∨ p ∨¬s ∨¬r ∨¬t ∨ u

d) (p ∧ r ∧ t) ↔(q ∧ t)

9. Construct a truth table for each of these compound propositions.

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)

10. Use truth tables to verify these equivalences.

a) p ∧ T ≡ p

b) p ∨ F ≡ p

c) p ∧ F ≡F

d) p ∨ T ≡ T

e) p ∨ p ≡ p

f)p∧p≡p

11. Use a truth table to verify the first De Morgan law

¬(p ∧ q) ≡ ¬p ∨¬q

12. Use De Morgan’s laws to find the negation of each of the following statements.

a) Ibrahim is smart and hard working.

b) Carlos will bicycle or run tomorrow.

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)

e) ¬(p → q) → p f ) ¬(p → q)→¬q

14. Determine whether (¬p ∧ (p → q))→¬q is a tautology.


15. Show that (p → q) ∧ (q → r) → (p → r) is a tautology.
16. Show that (p ∨ q) ∧ (¬p ∨ r) → (q ∨ r) is a tautology.
17. Show that (p → q) → r and p → (q → r) are not logically equivalent.
18. Show that (p ∧ q) → r and (p → r) ∧ (q → r) are not logically equivalent.
19. Show that (p → q) → (r → s) and (p → r) →(q → s) are not logically equivalent.

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)

21. Determine whether each of these compound propositions is satisfiable.

a) (p ∨¬q) ∧ (¬p ∨ q) ∧ (¬p ∨¬q)

b) (p → q) ∧ (p →¬q) ∧ (¬p → q) ∧ (¬p →¬q)

c) (p ↔ q) ∧ (¬p ↔ q)
Course Title: Discrete Structures
Course Code: CS201

Assignment#2

Prof. Dr. Khaled F. Hussain

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++.

d) No student at your school 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)

b) ∃x(x4 < x2)

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.

a) Everyone is studying discrete mathematics.


b) Everyone is older than 21 years.

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)

11. Suppose that the domain ofQ(x, y, z) consists of triples x, y, z, where x = 0, 1, or 2, y = 0 or 1,


and z = 0 or 1. Write out these propositions using disjunctions and conjunctions.

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.

a) Lois has asked Professor Michaels a question.

b) Every student has asked Professor Gross a question.

c) Every faculty member has either asked Professor Miller a question or been asked a
question by Professor Miller.

d) Some student has not asked any faculty member a question.

e) There is a faculty member who has never been asked a question by a student.

f ) Some student has asked every faculty member a question.

g) There is a faculty member who has asked every other faculty member a question.

h) Some student has never been asked a question by a faculty member.

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)

b) ∀x∀y(((x ≥ 0) ∧ (y < 0)) → (x −y > 0))

c) ∃x∃y(((x ≤ 0) ∧ (y ≤ 0)) ∧ (x −y > 0))

d) ∀x∀y((x _≠ 0) ∧ (y _= 0) ↔ (xy _≠ 0))

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)

18. What rule of inference is used in each of these arguments?


a) Alice is a mathematics major. Therefore, Alice is either a mathematics major or a
computer science major.
b) Jerry is a mathematics major and a computer science major. Therefore, Jerry is a
mathematics major.
c) If it is rainy, then the pool will be closed. It is rainy. Therefore, the pool is closed.
d) If it snows today, the university will close. The university is not closed today.
Therefore, it did not snow today.
e) If I go swimming, then I will stay in the sun too long. If I stay in the sun too long, then I
will sunburn. Therefore, if I go swimming, then I will sunburn.

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.

b) Every computer science major takes discrete mathematics. Natasha is taking


discrete mathematics. Therefore, Natasha is a computer science major.

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.

a) If it rains today, then I will drive to work.

b) If |x| = x, then x ≥ 0.

c) If n is greater than 3, then n2 is greater than 9.

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

Prof. Dr. Khaled F. Hussain

1. List the members of these sets.

a) {x | x is a real number such that x2 = 1}

b) {x | x is a positive integer less than 12}

c) {x | x is the square of an integer and x < 100}

d) {x | x is an integer such that x2 = 2}

2. Use set builder notation to give a description of each of these sets.

a) {0, 3, 6, 9, 12}

b) {−3,−2,−1, 0, 1, 2, 3}

c) {m, n, o, p}

3. Determine whether each of these pairs of sets are equal.


a) {1, 3, 3, 3, 5, 5, 5, 5, 5}, {5, 3, 1}
b) {{1}}, {1, {1}}

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.

5. Use a Venn diagram to illustrate the relationship A ⊆ B and B ⊆ C.


6. Use a Venn diagram to illustrate the relationships A ⊂ B and B ⊂ C.

7. Find the power set of each of these sets, where a and b are distinct elements.
a) {a}

b) {a, b}

8. Let A = {a, b, c, d} and B = {y, z}. Find


a) 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

11. Let A = {1, 2, 3, 4, 5} and B = {0, 3, 6}. Find


a) A ∪ B.

b) A ∩ B.

c) A − B.

d) B − A.

12. Show that if A and B are sets, then


a) A − B = A ∩ B.

b) (A ∩ B) ∪ (A ∩ B) = A.

13. Let A, B, and C be sets. Show that (A − B) − C = (A − C) − (B − C).

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.

15. Why is f not a function from R to R if


a) f (x) = 1/x?
b) f (x) =√x?
c) f (x) = ±√ (x2 + 1)?

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

17. Find the domain and range of these functions.


a) the function that assigns to each pair of positive integers the first integer of the pair
b) the function that assigns to each positive integer its largest decimal digit
c) the function that assigns to a bit string the number of ones minus the number of zeros
in the string
d) the function that assigns to each positive integer the largest integer not exceeding the
square root of the integer
e) the function that assigns to a bit string the longest string of ones in the string

18. Find the domain and range of these functions.


a) the function that assigns to each pair of positive integers the maximum of these two
integers
b) the function that assigns to each positive integer the number of the digits 0, 1, 2, 3, 4,
5, 6, 7, 8, 9 that do not appear as decimal digits of the integer
c) the function that assigns to a bit string the number of times the block 11 appears
d) the function that assigns to a bit string the numerical position of the first 1 in the string
and that assigns the value 0 to a bit string consisting of all 0s

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

21. Determine whether each of these functions from Z to Z is one-to-one.


a) f (n) = n − 1
b) f (n) = n2 + 1
c) f (n) = n3

22. Determine whether each of these functions from Z to Z is onto.


a) f (n) = n − 1
b) f (n) = n2 + 1
c) f (n) = n3

23. Give an example of a function from N to N that is


a) one-to-one but not onto.
b) onto but not one-to-one.
24. Determine whether each of these functions is a bijection from R to R.
a) f (x) = −3x + 4
b) f (x) = −3x2 + 7
c) f (x) = (x + 1)/(x + 2)
d) f (x) = x5 + 1

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.

26. Suppose that g is a function from A to B and f is a function from B to C.


a) Show that if both f and g are one-to-one functions, then f ◦ g is also one-to-one.
b) Show that if both f and g are onto functions, then f ◦ g is also onto.

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

Prof. Dr. Khaled F. Hussain

1. Does 17 divide each of these numbers?

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.

3. What are the quotient and remainder when

a) 19 is divided by 7?

b) −111 is divided by 11?

c) 789 is divided by 23?

d) 1001 is divided by 13?

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).

b) c ≡ 11b (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.

6. Evaluate these quantities.

a) −17 mod 2

b) 144 mod 7

c) −101 mod 13

d) 199 mod 19

7. Find a div m and a mod m when

a) a = −111, m = 99.

b) a = −9999, m = 101.

c) a = 10299, m = 999.

d) a = 123456, m = 1001.

8. Find the integer a such that

a) a ≡ 43 (mod 23) and −22 ≤ a ≤ 0.

b) a ≡ 17 (mod 29) and −14 ≤ a ≤ 14.

c) a ≡ −11 (mod 21) and 90 ≤ a ≤ 110.

9. List five integers that are congruent to 4 modulo 12.

10. Determine whether each of these integers is prime.

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

b) 2 ・ 3 ・ 5 ・ 7 ・ 11 ・ 13, 211 ・ 39 ・ 11 ・ 1714

13. What are the least common multiple of these pairs of integers?

a) 22 ・ 33 ・ 55, 25 ・ 33 ・ 52

b) 2 ・ 3 ・ 5 ・ 7 ・ 11 ・ 13, 211 ・ 39 ・ 11 ・ 1714

14. Find gcd(1000, 625) and lcm(1000, 625) and verify that gcd(1000, 625) ・ lcm(1000, 625) = 1000
・ 625.

15. Use the Euclidean algorithm to find

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

Prof. Dr. Khaled F. Hussain

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.

3. Prove that 12 + 32 + 52 +· · ·+(2n + 1)2 = (n + 1) (2n + 1)(2n + 3)/3 whenever n is a nonnegative


integer.

4. Prove that 1 · 1! + 2 · 2!+· · ·+n · n! = (n + 1)! – 1 whenever n is a positive integer.

5. Prove that 3+3 · 5+3 · 52+ · · · + 3 · 5n=3(5n+1−1)/4 whenever n is a nonnegative integer.

6. Prove that 2 − 2 · 7 + 2 · 72 −· · ·+2(−7)n = (1 − (−7)n+1)/4 whenever n is a nonnegative 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

Prof. Dr. Khaled F. Hussain

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

Prof. Dr. Khaled F. Hussain

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)}.

9. Which of these relations on {0, 1, 2, 3} are equivalence relations? Determine the


properties of an equivalence relation that the others lack.
a) {(0, 0), (1, 1), (2, 2), (3, 3)}
b) {(0, 0), (0, 2), (2, 0), (2, 2), (2, 3), (3, 2), (3, 3)}
c) {(0, 0), (1, 1), (1, 2), (2, 1), (2, 2), (3, 3)}
d) {(0, 0), (1, 1), (1, 3), (2, 2), (2, 3), (3, 1), (3, 2), (3, 3)}
e) {(0, 0), (0, 1), (0, 2), (1, 0), (1, 1), (1, 2), (2, 0), (2, 2), (3, 3)}

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

Prof. Dr. Khaled F. Hussain

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.

8. Draw a graph with the given adjacency matrix.

9. Represent the given graph using an adjacency matrix.

10. Draw an undirected graph represented by the given adjacency matrix.


Course Title: Discrete Structures
Course Code: CS201

Assignment#9

Prof. Dr. Khaled F. Hussain

1. Which of these graphs are trees?

2. Answer these questions about the rooted tree illustrated.

a) Which vertex is the root?


b) Which vertices are internal?
c) Which vertices are leaves?
d) Which vertices are children of j?
e) Which vertex is the parent of h?
f) Which vertices are siblings of o?
g) Which vertices are ancestors of m?
h) Which vertices are descendants of b?
i) What is the level of each vertex of the rooted tree?
3. Answer these questions about the rooted tree illustrated.

j) Which vertex is the root?


k) Which vertices are internal?
l) Which vertices are leaves?
m) Which vertices are children of j?
n) Which vertex is the parent of h?
o) Which vertices are siblings of o?
p) Which vertices are ancestors of m?
q) Which vertices are descendants of b?
r) What is the level of each vertex of the rooted tree?

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?

13. Construct the ordered rooted tree whose preorder traversal is a, b, f, c, g, h, i, d, e, j, k, l,


where a has four children, c has three children, j has two children, b and e have one
child each, and all other vertices are leaves.

You might also like