Final Review - people.engr.tamu.edu

34
CSCE 222 Discrete Structures for Computing Final Review Hyunyoung Lee 1

Transcript of Final Review - people.engr.tamu.edu

Page 1: Final Review - people.engr.tamu.edu

CSCE 222Discrete Structures for Computing

Final Review

Hyunyoung Lee

1

Page 2: Final Review - people.engr.tamu.edu

Final Exam

Tuesday, 12/10/2013 starting at 8:15am in our classroom

2

Page 3: Final Review - people.engr.tamu.edu

Topics

3

SYLLABUS

Course title and numberCourse title and number CSCE 222 Discrete Structures for ComputingCSCE 222 Discrete Structures for ComputingTermTerm Fall 2013Fall 2013Meeting times and locationMeeting times and location MWF 10:20-11:10 am, HRBB 124MWF 10:20-11:10 am, HRBB 124

Course Description and PrerequisitesCourse Description and PrerequisitesCourse Description and PrerequisitesCourse Description and PrerequisitesThe course provides the mathematical foundations from discrete mathematics for analyzing computer algorithms, for both correctness and performance; introduction to models of computation, including finite state machines and Turing machines. Prerequisite: MATH 151

The course provides the mathematical foundations from discrete mathematics for analyzing computer algorithms, for both correctness and performance; introduction to models of computation, including finite state machines and Turing machines. Prerequisite: MATH 151

The course provides the mathematical foundations from discrete mathematics for analyzing computer algorithms, for both correctness and performance; introduction to models of computation, including finite state machines and Turing machines. Prerequisite: MATH 151

The course provides the mathematical foundations from discrete mathematics for analyzing computer algorithms, for both correctness and performance; introduction to models of computation, including finite state machines and Turing machines. Prerequisite: MATH 151

Learning Outcomes or Course ObjectivesLearning Outcomes or Course ObjectivesLearning Outcomes or Course ObjectivesLearning Outcomes or Course ObjectivesAt the end of the course, students will understand the basic principles of logic, proofs and sets. They will be able to apply results from discrete mathematics to analysis of algorithms. They will be able to produce proofs by induction and apply counting techniques. They will have a basic understanding of models of computation.

At the end of the course, students will understand the basic principles of logic, proofs and sets. They will be able to apply results from discrete mathematics to analysis of algorithms. They will be able to produce proofs by induction and apply counting techniques. They will have a basic understanding of models of computation.

At the end of the course, students will understand the basic principles of logic, proofs and sets. They will be able to apply results from discrete mathematics to analysis of algorithms. They will be able to produce proofs by induction and apply counting techniques. They will have a basic understanding of models of computation.

At the end of the course, students will understand the basic principles of logic, proofs and sets. They will be able to apply results from discrete mathematics to analysis of algorithms. They will be able to produce proofs by induction and apply counting techniques. They will have a basic understanding of models of computation.

Instructor InformationInstructor InformationInstructor InformationInstructor Information

Name Prof. Dr. Hyunyoung LeeProf. Dr. Hyunyoung LeeProf. Dr. Hyunyoung LeeTelephone number 979 845 2490979 845 2490979 845 2490Email address hlee @ cse.tamu.eduhlee @ cse.tamu.eduhlee @ cse.tamu.eduOffice hours Monday and Tuesday 1:30-2:30pm or by appointmentMonday and Tuesday 1:30-2:30pm or by appointmentMonday and Tuesday 1:30-2:30pm or by appointmentOffice location HRBB 410BHRBB 410BHRBB 410B

Textbook and Resource MaterialTextbook and Resource MaterialTextbook and Resource MaterialTextbook and Resource MaterialKenneth Rosen, Discrete Mathematics and Its Applications, 7th ed., McGraw-Hill, 2012 Course home page: http://faculty.cse.tamu.edu/hlee/csce222Kenneth Rosen, Discrete Mathematics and Its Applications, 7th ed., McGraw-Hill, 2012 Course home page: http://faculty.cse.tamu.edu/hlee/csce222Kenneth Rosen, Discrete Mathematics and Its Applications, 7th ed., McGraw-Hill, 2012 Course home page: http://faculty.cse.tamu.edu/hlee/csce222Kenneth Rosen, Discrete Mathematics and Its Applications, 7th ed., McGraw-Hill, 2012 Course home page: http://faculty.cse.tamu.edu/hlee/csce222

Course Topics, Calendar of Activities, Major Assignment Dates (Tentative)Course Topics, Calendar of Activities, Major Assignment Dates (Tentative)Course Topics, Calendar of Activities, Major Assignment Dates (Tentative)Course Topics, Calendar of Activities, Major Assignment Dates (Tentative)

Week Topic Reading

8/26-8/30 Sets, Functions, and Algorithms Chapter 2

9/2-9/6 Algorithms and their Complexity Chapter 3

9/9-9/13 Logic and Proofs Chapter 1

9/16-9/20 Logic and Proofs Chapter 1

9/23-9/27 Sequences and Sums Chapter 2

9/30-10/4 Induction and Recursion Chapter 5

10/7-10/11 Induction and Recursion Chapter 5

10/14-10/18 Counting Chapter 6

10/21-10/25 Solving Recurrences Chapter 8

- 1 -

Week Topic Reading

10/28-11/1 Solving Recurrences Chapter 8

11/4-11/8 Relations Chapter 9

11/11-11/15 Models of Computation Chapter 13

11/18-11/22 Models of Computation Chapter 13

11/25-12/2 Models of Computation; Applications; Review Chapter 13

Tentative dates for Midterm 1: Wednesday 9/25/2013 in classMidterm 2: Wednesday 10/30/2013 in classFinal exam: Tuesday 12/10/2013 starting at 8:15am in our classroom.

Grading Scheme and Course Requirements1. Attendance PolicyClass attendance is strongly recommended. The student is responsible for any material missed. Missed exams may be made up only when the absence is university sanctioned. Medical reasons or other extenuating conditions beyond the control of the student must be properly documented. Discuss unusual circumstances in advance with the instructor when possible.

2. Grading SchemeYour grade will be based on the following components:exams 65% - There will be two mid-term exams each worth 20% and one comprehensive final exam worth 25%. The exams will be held in class and are closed book and closed notes unless otherwise stated.homework 35% - These are pencil and paper exercises and possibly programming assignments. All assignments will be announced in class and posted on the course home page. If you miss class for any reason, it is your responsibility to find out what assignments you missed. Your lowest homework grade will be dropped.

Final grades will be assigned according to this scale: A: 90 and above, B: 80-89, C: 70-79, D: 60-69, F: below 60The scale may be adjusted by the Instructor to reflect score variations.

3. Deadline PolicyTurn in all work by the established deadline. In case you have difficulties finishing an assignment contact the Instructor before the deadline. Late work can be accepted only under circumstances beyond the student's control and after arrangement with the Instructor prior to the deadline. Note: work turned-in on time is eligible for partial credit. It will always be better to turn work in by the deadline, as trying to ‘perfect’ it and turning it in late will give you no points at all.

4. Submission of Work and Late Submission PolicyAll assignments must be submitted electronically using the CSNET portal by the due date and time and an honor-code signed hardcopy must be turned in in the beginning of class of the due date. Late submission beyond the cutoff will not be accepted in general, unless a University sanctioned excuse is provided ahead of time. A student will earn points when he/she submits the assignment on time. Note that email submissions will not be accepted (they will be ignored without notice). You have to follow the submission and media policies and guidelines published on the web.

5. Re-grading PolicyA student can request re-grading of assignments and exams, if he/she believes that the points assigned are inconsistent with the quality and merits of the submitted work. To request re-grading you have to follow the guidelines below.

1. Re-grading requests must be submitted AT MOST ONE WEEK AFTER the item has been graded and returned to the student and solutions have been made public. After this time limit NO re-grading requests will be honored.

- 2 -

Page 4: Final Review - people.engr.tamu.edu

Logical Connectives - Summary

Let B={t,f}. Assign to each connective a function M: B->B

that determines its semantics. 4 The Semantics of Propositional Logic

Let B = {t, f} denote the set of truth values, where t and f represent trueand false, respectively. We associate to the logical connective ¬ the functionM¬ : B→ B given by

P M¬(P )f tt f

Thus, M¬(P ) is true if and only if P is false. This justifies the name negationfor this connective. The graph of the function M¬ given above is called thetruth table of the negation connective. Similarly, we associate to a connectiveX in the set {∧,∨,⊕,→,↔} a binary function MX : B × B → B. The truthtables of these connectives are as follows:

P Q M∧(P, Q) M∨(P,Q) M⊕(P, Q) M→(P, Q) M↔(P, Q)f f f f f t tf t f t t t ft f f t t f ft t t t f t t

You should very carefully inspect this table! It is critical that you memorizeand fully understand the meaning of each connective.

The semantics of the language Prop is given by assigning truth values toeach proposition in Prop. Clearly, an arbitrary assignment of truth values isnot interesting, since we would like everything to be consistent with the meaningof the connectives that we have just learned. For example, if the propositions aand b have been assigned the value t, then it is reasonable to insist that a ∧ bbe assigned the value t as well. Therefore, we will introduce the concept of avaluation, which models the semantics of Prop in an appropriate way.

A valuation v : Prop→ B is a function that assigns a truth value to eachproposition in Prop such thatV1. v�¬a� = M¬(v�a�)V2. v�(a ∧ b)� = M∧(v�a� , v�b�)V3. v�(a ∨ b)� = M∨(v�a� , v�b�)V4. v�(a⊕ b)� = M⊕(v�a� , v�b�)V5. v�(a→ b)� = M→(v�a� , v�b�)V6. v�(a↔ b)� = M↔(v�a� , v�b�)holds for all propositions a and b in Prop. The properties V1–V6 ensurethat the valuation respects the meaning of the connectives. We can restrict avaluation v to a subset of the set of proposition. If A and B are subsets ofProp such that A ⊆ B, and vA : A → B and vB : B → B are valuations, thenvB is called an extension of the valuation vA if and only if vB coincides withvA when restricted to A.

The consistency conditions V1-V6 are quite stringent, as the next theoremshows.

5

4 The Semantics of Propositional Logic

Let B = {t, f} denote the set of truth values, where t and f represent trueand false, respectively. We associate to the logical connective ¬ the functionM¬ : B→ B given by

P M¬(P )f tt f

Thus, M¬(P ) is true if and only if P is false. This justifies the name negationfor this connective. The graph of the function M¬ given above is called thetruth table of the negation connective. Similarly, we associate to a connectiveX in the set {∧,∨,⊕,→,↔} a binary function MX : B × B → B. The truthtables of these connectives are as follows:

P Q M∧(P, Q) M∨(P,Q) M⊕(P, Q) M→(P, Q) M↔(P, Q)f f f f f t tf t f t t t ft f f t t f ft t t t f t t

You should very carefully inspect this table! It is critical that you memorizeand fully understand the meaning of each connective.

The semantics of the language Prop is given by assigning truth values toeach proposition in Prop. Clearly, an arbitrary assignment of truth values isnot interesting, since we would like everything to be consistent with the meaningof the connectives that we have just learned. For example, if the propositions aand b have been assigned the value t, then it is reasonable to insist that a ∧ bbe assigned the value t as well. Therefore, we will introduce the concept of avaluation, which models the semantics of Prop in an appropriate way.

A valuation v : Prop→ B is a function that assigns a truth value to eachproposition in Prop such thatV1. v�¬a� = M¬(v�a�)V2. v�(a ∧ b)� = M∧(v�a� , v�b�)V3. v�(a ∨ b)� = M∨(v�a� , v�b�)V4. v�(a⊕ b)� = M⊕(v�a� , v�b�)V5. v�(a→ b)� = M→(v�a� , v�b�)V6. v�(a↔ b)� = M↔(v�a� , v�b�)holds for all propositions a and b in Prop. The properties V1–V6 ensurethat the valuation respects the meaning of the connectives. We can restrict avaluation v to a subset of the set of proposition. If A and B are subsets ofProp such that A ⊆ B, and vA : A → B and vB : B → B are valuations, thenvB is called an extension of the valuation vA if and only if vB coincides withvA when restricted to A.

The consistency conditions V1-V6 are quite stringent, as the next theoremshows.

5

4

Page 5: Final Review - people.engr.tamu.edu

Conditional

Perhaps the most important logical connective is the conditional, also known as implication:

p -> q

The statement asserts that q holds on the condition that p holds. We call p the hypothesis or premise, and q the conclusion or consequence. Typical usage in proofs:

“If p, then q”; “p implies q”; “q when p”; “q follows from p”

“p is sufficient for q”; “a sufficient condition for q is p”; “a necessary condition for p is q”; “q is necessary for p”

5

Page 6: Final Review - people.engr.tamu.edu

Logical Equivalence

Two statements involving quantifiers and predicates are logically equivalent if and only if they have the same truth values no matter which predicates are substituted into these statements and which domain is used.

We write A ≡ B for logically equivalent A and B.

You use logical equivalences to derive more convenient forms of statements.

Example: De Morgan’s laws.

6

Page 7: Final Review - people.engr.tamu.edu

De Morgan’s Laws

¬∀xP (x) ≡ ∃x¬P (x)

¬∃xP (x) ≡ ∀x¬P (x)

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

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

7

Page 8: Final Review - people.engr.tamu.edu

Valid Arguments

An argument in propositional logic is a sequence of propositions that end with a proposition called conclusion. The argument is called valid if the conclusion follows from the preceding statements (called premises).

In other words, in a valid argument it is impossible that all premises are true but the conclusion is false.

8

Page 9: Final Review - people.engr.tamu.edu

Modus Ponens

The tautology (p ⋀ (p->q)) -> q is the basis for the rule of inference called “modus ponens”.

p

p -> q

-------

∴ q

9

Page 10: Final Review - people.engr.tamu.edu

Modus Tollens

¬q

p -> q

------

∴¬ p

“The University will not close on Wednesday.”

“If it snows on Wednesday, then the University will close.”

Therefore, “It will not snow on Wednesday”

10

Page 11: Final Review - people.engr.tamu.edu

Formal Argument

¬p ∧ qr → p¬r → ss → t

∴ t

Argument

1) ¬p ∧ q Hypothesis

2) ¬p Simplification of 1)

3) r → p Hypothesis

4) ¬r Modus tollens using 2) and 3)

5) ¬r → s Hyposthesis

6) s Modus ponens using 4), 5)

7) s → t Hypothesis

8) t Modus ponens using 6), 7)

11

Page 12: Final Review - people.engr.tamu.edu

Proofs

Direct Proof

Proof by Contradiction

Proof by Induction

- weak induction

- strong induction

- structural induction

- transfinite induction (= induction over well-ordered sets)

12

Page 13: Final Review - people.engr.tamu.edu

Set Theory

You should be familiar with

- the builder notation

- subsets, equality of sets

- union, intersection, set difference, complement

- cartesian product, power set

- cardinality of sets (when is |A| <= |B|?)

- countable and uncountable sets

13

Page 14: Final Review - people.engr.tamu.edu

De Morgan Laws

A ∩B = A ∪B

Proof :

A ∩B = {x | x �∈ A ∩B} by definition of complement

= {x | ¬(x ∈ A ∩B)}= {x | ¬(x ∈ A ∧ x ∈ B)} by definition of intersection

= {x | ¬(x ∈ A) ∨ ¬(x ∈ B)} de Morgan’s law from logic

= {x | (x �∈ A) ∨ (x �∈ B)} by definition of �∈= {x | x ∈ A ∨ x ∈ B} by definition of complement

= {x | x ∈ A ∪B} by definition of union

= A ∪B

14

Page 15: Final Review - people.engr.tamu.edu

Functions

Let f: A -> B be a function.

We call

- A the domain of f and

- B the codomain of f.

The range of f is the set

f(A) = { f(a) | a in A }

15

Page 16: Final Review - people.engr.tamu.edu

Functions

Let A and B be sets. Consider a function f: A-> B.

- When is f surjective?

- When is f injective?

- When is f bijective?

16

Page 17: Final Review - people.engr.tamu.edu

Floor and Ceiling Functions

The floor function ⎣⎦: R -> Z assigns to a real

number x the largest integer <= x.

The ceiling function ⎡⎤: R -> Z assigns to a real

number x the smallest integer >= x.

⎣3.2⎦= 3 and ⎡3.2⎤= 4

⎣-3.2⎦= -4 and ⎡-3.2⎤= -3

17

Page 18: Final Review - people.engr.tamu.edu

Basic Facts

We have⎣x⎦= n if and only if n <= x < n+1.

We have⎡x⎤=n if and only if n-1< x <= n.

We have⎣x⎦= n if and only if x-1 < n <= x.

We have⎡x⎤=n if and only if x<= n < x+1.

18

Page 19: Final Review - people.engr.tamu.edu

Example

19

Prove or disprove:

��

�x�� = �√x�

Page 20: Final Review - people.engr.tamu.edu

Example 3

20

Let m = ���x��

Hence, m ≤��x� < m+ 1

Thus, m2 ≤ �x� < (m+ 1)2

It follows that m2 ≤ x < (m+ 1)2

Therefore, m ≤√x < m+ 1

Thus, we can conclude that m = �√x�

This proves our claim.

Page 21: Final Review - people.engr.tamu.edu

Series and Sums

You need to know

- sequence notations

- important sequences

- summation notation

- geometric sum

- sum of first n positive integers

21

Page 22: Final Review - people.engr.tamu.edu

Geometric SeriesIf a and r �= 0 are real numbers, then

n�

j=0

arj =

�arn+1−a

r−1 if r �= 1

(n+ 1)a if r = 1

Proof:The case r = 1 holds, since arj = a for each of then+ 1 terms of the sum.

The case r �= 1 holds, since

(r − 1)�n

j=0 arj =

n�

j=0

arj+1 −n�

j=0

arj

=n+1�

j=1

arj −n�

j=0

arj

= arn+1 − aand dividing by (r − 1) yields the claim.

Extremely useful!

22

Page 23: Final Review - people.engr.tamu.edu

Sum of First n Positive Integers .

For all n ≥ 1, we haven�

k=1

k = n(n+ 1)/2

We prove this by induction.Basis step: For n = 1, we have

1�

k=1

k = 1 = 1(1 + 1)/2.

Extremely useful!

23

Page 24: Final Review - people.engr.tamu.edu

Infinite Geometric Series

Let x be a real number such that |x| < 1. Then

∞�

k=0

xk =1

1− x.

24

Page 25: Final Review - people.engr.tamu.edu

Asymptotic Notations

You need to know

- big Oh notation

- big Omega notation

- big Theta notation

- be able to prove that f = O(g), ...

- be able to show that O(g)=O(h)

25

Page 26: Final Review - people.engr.tamu.edu

Big Oh Notation

Let f,g: N -> R be functions from the natural numbers to the set of real numbers.

We write f ∈ O(g) if and only if there exists some real number n0 and a positive real constant U such that |f(n)| <= U|g(n)| for all n satisfying n >= n0

26

Page 27: Final Review - people.engr.tamu.edu

Big Ω

We define f(n) = Ω(g(n)) if and only if there exists a constant L and a natural number n0 such that

L |g(n)| <= |f(n)|

holds for all n >= n0.

In other words, f(n) = Ω(g(n)) if and only if g(n) = O(f(n)).

27

Page 28: Final Review - people.engr.tamu.edu

Big Θ

We define f(n) = Θ(g(n)) if and only if there exist constants L and U and a natural number n0 such that

L|g(n)| <= |f(n)| <= U|g(n)|

holds for all n >= n0.

In other words, f(n) = Θ(g(n)) if and only if

f(n) = Ω(g(n)) and f(n) = O(g(n)).

28

Page 29: Final Review - people.engr.tamu.edu

Counting

You need to know

- the basic counting principles (product rule, sum rule,...)

- (generalized) pigeonhole principle

- permutations and combinations

- binomial coefficients

- binomial theorem

- counting with repeated elements

29

Page 30: Final Review - people.engr.tamu.edu

Pigeonhole Principle

In any cocktail party n >=2 people, there must be at least two people who have the same number of friends (assuming that the friends relation is symmetric and irreflexive).

The number of friends of each person ranges between 0 and n-1.

Case 1: Everyone has at least one friend.

If everyone has at least one friend, then each person has between 1 to n-1 friends. Since we have n people, and just n-1 different values, there must be two partygoers that have the same number of friends by the pigeonhole principle.

Case 2: Someone has no friends.

If someone lacks any friends, then that person is a stranger to all other guests. Because friend is symmetric, the highest value anyone else could have is n - 2, that is, everyone has between 0 to n – 2 friends. Since we have n people, and just n-1 different values, there must be two partygoers that have the same number of friends by the pigeonhole principle.

Page 31: Final Review - people.engr.tamu.edu

Solving Recurrences

You need to be able to solve recurrences by

- solving characteristic equations (for homogeneous linear recurrences of degree 2)

- by inspecting, guessing, and verifying a solution

- by applying the master theorem

31

Page 32: Final Review - people.engr.tamu.edu

Relations

You need to know

- the basic properties of relations (reflexive, symmetric, antisymmetric, transitive, ...)

- how to show that a relation is an equivalence relation

- the congruence relation mod m

- how to show that a relation is a partial order

- what an order lattice is

32

Page 33: Final Review - people.engr.tamu.edu

Formal Languages

You need to

- be familiar with the Chomsky Hierarchy

- be able to determine the language associated with a grammar

- know the characterization of regular languages as languages accepted by finite state automata or languages described by regular expressions

- be familiar with finite state machines and finite state automata

33

Page 34: Final Review - people.engr.tamu.edu

Hints

Read the textbook and the class notes.

Study old exams, quizzes, homeworks.

Drill using odd numbered exercises.

Scan through review sections of the textbook.

Get enough sleep!!

34