Discretemath
Discretemath
(XOR)
p⊕q
F
T
T
F
interactions between finite sets, and
analyzing processes with a finite number of
steps.
p↔q
• It is concerned with the validity of arguments,
T
F
F
T
the truth of statements, and the relationship
between different propositions.
p→q
(IF)
T
F
T
T
be either true or false, but not both.
Ex.
PROPOSITION NOT PROPOSITION
The earth is flat. Questions(?) (OR)
pVq
T
T
T
F
It will rain tomorrow. Exclamation(!)
T
F
F
F
propositions—declarative statements that
can be classified as either true or false.
~q /¬q
F
T
F
T
letters.
• The value of a proposition (p) is called its
TRUTH VALUE.
p
T
F
q
T or 1
F or 0
COMPOUND PROPOSITIONS
• proposition constructed by combining one
T
F
p
Q: p ∧ ¬q CONTINGENCY
p q ¬q p ∧ ¬q
T T F F
T F T T
F T F F
F F T F • Invented by an English mathematician, John
Is P logically equivalent to Q? NO 𝑃 ≢ 𝑄 Venn (1834-1923) to illustrate ideas in his
2. If it is sunny or the temperature is above 20°C, text on symbolic logic, published 1881.
then Sarah will go to the park.
Propositions: Elements(Є)
p: it is sunny • It denotes “belongs to” or “is an element
q: the temperature is above 20°C of” a set.
r: Sarah will go to the park Ex. A = {4, 5, 6} then 4 ∈ A, 7 ∉ A
Symbol: (p ∨ q) → r
Truth table: Cardinal number – number of elements in a set.
p q r (p ∨ q) (p ∨ q) → r • Symbolized by n(A) or |A|.
Subset
- Set contained in a larger set or in an equal set.
- Denoted by ⊆
A={4,5,6} B={1,2,3,4,5,6,7,8,9} A⊆B SET UNION
A={...,-8, B={...,-8,-6,-4, A⊈B
• Set made of elements from the universal set
-4,0,4,8,...} -2,0,2,4,6,8}
where it is either from subset A or B or both
Proper Subset • Denoted by ∪
• It is a subset that is not equal to the set it • Expressed as 𝐴 ∪ 𝐵 = {𝑥 ∈ 𝑈|𝑥 ∈ 𝐴 ∨
belongs to. x ∈ B}
• Denoted with ⊂
A={4,5,6} B={1,2,3,4,5,6,7,8,9} A⊂B
Note: List all distinct subsets when finding the no. SET DIFFERENCE
of subsets/proper subsets. • Set made by elements from a subset
without the common elements in another
Null Set – empty set/ set with no elements subset
• Denoted by {} or ∅ • Denoted by A-B
• Expressed as A-𝐵 = {𝑥 ∈ 𝑈|𝑥 ∈ 𝐴 ∧
SET OPERATIONS x ∉ B}
SET COMPLEMENT
• Set of all elements that are in the universal
set (U) that isn’t in a specific subset.
• Denoted by A’ or A ̅
• Expressed as A' = {x ∈ U | x ∉ A}
SYMMETRIC DIFFERENCE
• Set made from elements of both subsets
without the common elements of both
subsets
• Denoted as A ⊕ B, (A-B) ∪ (B-A)
If student's grade is greater than or equal to 60
Print "passed"
else
Print "failed"
Pseudocode
RECURSION
ALGORITHMS • technique in programming that calls itself
• Finite set of instructions that specify a • has the capability to save the condition it
sequence of operations to be carried out was in or the particular process it was
• All the tasks that can be carried out by a serving when calling itself
computer can be stated as algorithms • can be written using ASSIGNMENT
STATEMENT, IF-ELSE STATEMENT and WHILE
CRITERIA STATEMENT
1. INPUT TYPES
2. OUTPUT 1. DIRECT – the function calls itself directly
3. DEFINITENESS – clear within the body
4. FINITENESS – countable
5. EFFECTIVENESS – feasible Ex. Factorial Calculator
STEPWISE REFINEMENT
• process by which a programmer refines an
initial idea to a problem’s solution into more
specific terms
• The last phase of refinement results in a
program ready to be coded for execution
ANALYSIS OF ALGORITHM
• Determining the number of resources such
as time and storage to execute a program
• Usually in terms of CPU time and memory