Exactly One!
Ayman Al Zaatari
CMPS 211 - Fall 2017
We need to check whether the following statements are true or false:
!xP (x) x1 P (x1 ) x2 : x1 6= x2 P (x2 )
and:
!xP (x) xP (x) x1 , x2 : P (x1 ) P (x2 ) x1 = x2
Lets consider that the domain of x consi

American University of Beirut
Department of Computer Science
CMPS 211 - Fall 2016-17
Assignment 1 - Solution
Propositional Logic
The following exercises are to be submitted on Friday, 16th September 2016
@ 10:00 a.m. Late submissions will not be accepted

Discrete Structures
Topic 0 - Introduction* and Syllabus overview
CMPS 211 Fall 2016 American University of Beirut
* Extracted from Discrete Mathematics and Its Applications book slides
1
Course Introduction
2
Mathematics
What is Mathematics to start wit

Discrete Structures
Topic 12 Basic Structures: Cardinality
(Ch 2.5)*
CMPS 211 Fall 2016 American University of Beirut
* Extracted from Discrete Mathematics and Its Applications book slides
1
Cardinality of Sets
2
Set Cardinality
The cardinality of a set

Discrete Structures
Topic 24 Recurrence Relations & Complexity
of Recursive Algorithms (Ch. 8.1)
CMPS 211 Fall 2016 American University of Beirut
* Extracted from Discrete Mathematics and Its Applications book slides
1
Recurrence Relations
2
Recurrence Re

Discrete Structures
Topic 18 Prog. Correctness Iterative Alg.
(Ch 5.5)*
CMPS 211 Fall 2016 American University of Beirut
* Extracted from Discrete Mathematics and Its Applications book slides
1
Program Correctness for
Iterative Algorithms
2
Program Correc

Discrete Structures
Topic 13 Basic Structures: Sequences
(Ch 2.4)*
CMPS 211 Fall 2016 American University of Beirut
* Extracted from Discrete Mathematics and Its Applications book slides
1
Introduction
Sequences are ordered lists of elements
1, 2, 3,

Discrete Structures
Topic 15 Ind.& Rec.: Strong Induction
(Ch 5.2)*
CMPS 211 Fall 2016 American University of Beirut
* Extracted from Discrete Mathematics and Its Applications book slides
1
Recall Mathematical Induction
Mathematical induction can be expre

Discrete Mathematics
CMPS 211
Nested Quantifiers
Section 1.5 in the textbook
Nested Quantifiers
Nested quantifiers are often necessary to express
the meaning of sentences in English as well as
important concepts in computer science and
mathematics
Example

Discrete Mathematics
CMPS 211
Applications of
Propositional Logic
Section 1.2 in the textbook
System Specifications
System and Software engineers take
requirements in English and express them in a
precise specification language based on logic
Example: Exp

Recitation 11
11/23/2016
I.
Assignment 7 Questions
II.
III.
IV.
V.
Write Selection sort recursively
VI.
Exercise 13
VII.
(10 points)
Write the recurrence relation describing the runtime of each of the following
recursive algorithms
a) int rec_ternary_sear

Recitation 12
11/30/2016
I.
II.
III.
IV.
V.
VI.
Write a recursive pow function, and show that its correct
VII.
A vendor sells ice cream from a cart on the boardwalk. He offers vanilla,
chocolate, strawberry, and pistachio ice cream, served on either a waf

American University of Beirut
Department of Computer Science
CMPS 211 - Fall 2016-17
Iter. Algs. Correctness
For each of the following algorithms, state a loop invariant and then prove it.
Algorithm 1: This procedure compute xn
Procedure power(integer x,

Induction on Partial Sums Recipe
Ayman Al Zaatari
CMPS 211 - Fall 2017
The following is a general recipe for proving that a certain partial sum of a sequence
has a given compact form by Mathematical Induction.
P
In other words, we need to show that for so

Recitation 1
21/9/2016
I. Solve problems from Assignment 1
1. Ex 1
2. Ex 5
3. Ex 6
II. Check if there are specific questions from students.
III. Express these propositions and their negations using quantifiers, and in
English.
1.
2.
3.
4.
There is a socce

Recitation 2
I. Solve problems from Assignment 2
1. Ex 1
2. Ex 4
3.
4. Ex 6
28/9/2016
5.
II. Check if there are specific questions from students.
III. Prove/disprove the following:
a)
b)
c)
d)
e)
f)
g)
h)
if a-b is odd, and b+c is odd, then a+c is even.
I

Recitation 3
6/10/2016
Solve problems from Assignment 3
I.
Exercise 12
II.
(10 points)
Formulate and proof a conjecture about the last digit (right most) of the 4th power
of any integer.
[(a + b)4 = a4 + 4a3b + 6a2b2 + 4ab3 + b4 . . . . . ]
III.
Exercise

Recitation 8
I.
2/11/2016
Problem 1 (20 Points)
a. (10) Use mathematical induction to prove that for r 1, n 0,
(1 +1 )
=0 = a + ar + ar2 + . + arn =
1r
b. (5) Use (b) above to show that for 0 < r < 1, the following holds:
1
2
=0 = 1 + r + r + . =
1r
c. (

Recitation 6
21/10/2016
I.
Let A, B, and C be sets. Show that:
a) (A B) (A B C)
b) (ABC) (AB)
c) (AC)(CB) =
d)
II.
Give an example of a function from Z to N that is
a) one-to-one but not onto.
b) onto but not one-to-one
c) both onto and one-to-one (but d

Recitation 9
I.
Exercise 5
I.
11/9/2016
(20 points)
Given a list of unsorted numbers of n elements, devise linear time algorithms
that:
a) locates the position of the element with value closest to the arithmetic mean of the list.
b) determines the max of

Discrete Mathematics
CMPS 211
Chapter 1: Logic
Why logic?
Logic is a set of principles that can be used to
reason about (mathematical) statements
For instance, lets say we want to formally
express and reason about the following
statement:
For every positi

Discrete Mathematics
CMPS 211
Predicate Logic
Section 1.4 in the textbook
Propositional Logic Not Enough
If we have
All men are mortal
Socrates is a man
Does it follow that Socrates is mortal?
Cant be represented in propositional logic
Need a language tha

Discrete Mathematics
CMPS 211
Propositional Equivalences
Section 1.3 in the textbook
Tautologies, Contradictions, and
Contingencies
A tautology is a proposition which is always
true
Example: p p
A contradiction is a proposition which is
always false
Examp

Discrete Mathematics
CMPS 211
Divide-and-Conquer Algorithms
and Recurrence Relations
Section 8.3 of the textbook
Divide-and-Conquer Algorithmic Paradigm
Definition: A divide-and-conquer algorithm works by
first dividing a problem into one or more instance

Discrete Mathematics
CMPS 211
The Basics of Counting
Section 6.1 of the textbook
Basic Counting Principles: The Product Rule
The Product Rule: A procedure can be broken
down into a sequence of two tasks. There are n1 ways
to do the first task and n2 ways

Discrete Mathematics
CMPS 211
Applications of
Recurrence Relations
Section 8.1 of the textbook
Recurrence Relations
Definition: A recurrence relation for the sequence
cfw_an is an equation that expresses an in terms of
one or more of the previous terms of

American University of Beirut
Department of Computer Science
CMPS 211 - Fall 2016-17
Assignment 8 - Solution
Recursion Algorithms
The following exercises are to be submitted during class on Tuesday, 6th
December 2016. Late submissions will not be accepted

American University of Beirut
Department of Computer Science
CMPS 211 - Fall 2016-17
Assignment 2 - Solution
Predicate Logic & Inferences
The following exercises are to be submitted on Wednesday, 28th September
2016 @ 4:00 a.m. Late submissions will not b

American University of Beirut
Department of Computer Science
CMPS 211 - Fall 2016-17
Assignment 5 - Solution
Sequences, Induction & Recursion
The following exercises are to be submitted on Monday, 31st October 2016 @
4:00 p.m. Late submissions will not be

American University of Beirut
Department of Computer Science
CMPS 211 - Fall 2016-17
Assignment 3 - Solution
Proofs
The following exercises are to be submitted on Wednesday, 5th October 2016
@ 4:00 a.m. Late submissions will not be accepted
You are expect

American University of Beirut
Department of Computer Science
CMPS 211 - Fall 2016-17
Assignment 7 Solution
Iterative Algorithms Correctness and Complexity &
Function Growth
The following exercises are to be submitted during class on Monday, 28th
November

American University of Beirut
Department of Computer Science
CMPS 211 - Fall 2016-17
Assignment 4 - Solution
Sets & Functions
The following exercises are to be submitted on Wednesday, 19th October 2016
@ 4:00 p.m. Late submissions will not be accepted
You