














Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
Material Type: Assignment; Professor: Cleave; Class: Elements of Discrete Mathematics; Subject: Mathematics; University: Eastern Illinois University; Term: Fall 2007;
Typology: Assignments
1 / 22
This page cannot be seen from the preview
Don't miss anything!
Nancy Van Cleave
Fall 2007
1
I (^) Syllabus
I Schedule (note exam dates)
I (^) Homework & Programs
I (^) Academic Integrity Guidelines
I Course Web Site
2
An introduction to the mathematical foundations needed by computer scientists. A survey of discrete sturctures and methods I (^) logic I (^) sets I (^) functions I (^) algorithms ñ developing and analyzing I (^) induction proofs I (^) recursion relations I (^) relations I (^) Boolean algebra, logic gates, circuits I (^) modeling computation ñ Finite State and Turing Machines
3
I (^) Mathematical Reasoning ñ induction
I (^) Mathematical Analysis ñ comparison of algorithms / functions
I (^) Discrete Structures ñ abstract math structures, the relationship between discrete and abstract structures
I (^) Algorithmic Thinking ñ algorithmic paradigms
I (^) Applications and Modeling ñ can we predict behavior?
4
I (^) Reading : Textbook, Sections 1.1 & 1.
I (^) Homework 1.1 : 2añd, 4añe, 6añe, 8añd, 20añc, 35 (show
propositions ó due in class on Friday
I (^) Homework 1.2 : 4, 8añb, 10añb, 18, 30, 32 ó due in class on Monday
I (^) Attendance
I (^) The rules of logic are used to distinguish between valid and invalid mathematical arguments.
I (^) Logic rules have many applications in computer science. They are used in: I (^) the design of computer circuits I (^) the construction of computer programs I (^) the verication of the correctness of programs I (^) as the basis of some Articial Intelligence programming languages. I (^) and many other ways as well
Propositions
false, but not both.
I (^) The zip code for Charleston, IL is 61920. I (^) The Will Roger's Theater is on Monroe Street. I (^1) + 4 = 5 I (^1) + 3 = 5 I (^) The title of our course is Mathemagics.
Counterexamples : I (^) Where am I? I (^) Stop! I (^) x + 2 y = 4
7
I (^) Variables are generally used to represent propositions: p ; q ; r ; s ; : : :
denoted by : p.
8
Truth Tables
values of propositions.
The truth table for negation :
T F F T
When proposition p is true, its negation is false. When it is false, its negation is true.
The negation of ìToday is Mondayî is ìToday is not Mondayî or ìIt is not the case that today is Mondayî
9
Conjunction
Let p = Today is Monday, and q = It is raining. What is the value of each of the following conjunctions?
10
Disjunction
T T T T T F F T F T F T F F F F
Exclusive Or
I ìFries or baked potato come with your mealî I (^) ìDo the dishes or go to your roomî
T T F T F T F T T F F F
Tricky Question
For p ∨ q , write each of the following:
Direct Statement :
Converse :
Inverse :
Contrapositive :
19
Alternate Conditional Forms
Common translations of p → q If p , then q p is sufcient for q If p , q q is necessary for p p implies q All p 's are q 's p only if q q if p
These translations do not in any way depend upon the truth value of p → q.
ì If you get home late, then you are grounded î ≡ You are grounded if you get home late. Getting home late is sufcient for you to get grounded. Getting grounded is necessary when you get home late. Getting home late implies that you are grounded. 20
Logical and Bit Operations
and can thus be represented by a bit.
applied to bit strings.
21
An Exercise
0101 1101 0011 p 1110 1011 0110 q bitwise OR bitwise AND bitwise XOR
22
1.2 Propositional Equivalences
nor a contradiction.
tautology contradiction
T F T F F T T F
Logical Equivalence
which always have the same truth value (given the same truth assignments to any Boolean Variables).
T T T T F F F F
T F F T F F T F F T F T F T F F
F F F F T T T T
On Worksheet Provided
Using a truth table, show that p ∧ q is logically equivalent to :[ p → (: q )]
Using a truth table, show that p ∨ q is logically equivalent to (: p ) → q
Using a truth table, show that p ∨ ( q ∧ r ) is logically equivalent to ( p ∨ q ) ∧ ( p ∨ r )
25
Write as a proposition:
Begin by breaking the compound into separate propositions:
26
Name that Term!
What is a proposition which
27
I (^) Two propositions, p and q , are logically equivalent if p ↔ q is a tautology.
I (^) We write p ⇔ q
I (^) Example: ( p → q ) ∧ ( q → p ) ⇔ p ↔ q
To show a proposition is not a tautology, use an abbreviated truth table and
I (^) try to nd a counter example or to disprove the assertion I (^) search for a case where the proposition is false
28
Proving Logical Equivalence
Prove these expressions are logically equivalent: ( p → q ) ∧ ( q → p ) ⇔ p ↔ q
When would they not be equivalent?
Case 1. left side false, right side true... Subcase a. p → q is false Subcase b. q → p is false
Case 2. left side true, right side false... Subcase a. p = T , q = F Subcase b. p = F , q = T There are no more possibilities, so the two propositions must be logically equivalent.
Note, Table 5 in section 1.2 ó these are important for simplifying propositions and proving logical equivalences.
The Porsche & The Tiger
A prisoner must make a choice between two doors: behind one is a beautiful red Porsche, and behind the other is a hungry tiger. Each door has a sign posted on it, but only one sign is true.
Door #1. IN THIS ROOM THERE IS A PORSCHE AND IN THE OTHER ROOM THERE IS A TIGER.
Door #2. IN ONE OF THESE ROOMS THERE IS A PORSCHE AND IN ONE OF THESE ROOMS THERE IS A TIGER.
With this information, the prisoner is able to choose the correct door... Which one is it?
Existential Quantication
proposition is true if and only if it is true for at least one value in the universe of discourse.
the proposition that P ( x ) is true for some x in the Universe of Discourse I (^) Existential quantication is written as: ∃ x P ( x ) I (^) For example, let U = f 1 ; 2 ; 3 g. Then ∃ x P ( x ) ⇔ P ( 1 ) ∨ P ( 2 ) ∨ P ( 3 ).
a proposition is true for one and only one x ∈ U , and is written ∃! x P ( x )
variables have been bound either by quantication or assignment of a value. 37
Equivalences Involving Negation
: ∀ x P ( x ) ⇔ ∃ x : P ( x ) ì P ( x ) is not true for all x î is logically equivalent to ì there is some x for which P ( x ) is not true î
: ∃ x P ( x ) ⇔ ∀ x : P ( x ) ì There is no x for which P ( x ) is true î is logically equivalent to ì P ( x ) is not true for every x”
I (^) Distributing a negation operator across a quantier changes a universal to an existential, and vice versa
I (^) If there are multiple quantiers, they are read from left to right
38
Examples
Let U = R, the real numbers. Then consider P ( x ; y ) : xy = 0 Which of the following are TRUE? I (^) ∀ x ∀ y P ( x ; y )
I (^) ∀ x ∃ y P ( x ; y )
I (^) ∃ x ∀ y P ( x ; y )
I (^) ∃ x ∃ y P ( x ; y )
Suppose P ( x ; y ) : xy = 1... now which are TRUE?
39
Conversions
Let U = f 1 ; 2 ; 3 g. Find an expression equivalent to: ∀ x ∃ y P ( x ; y ) where the variables are bound by substitution instead of quantication. We can expand from the inside out, or the ouside in... Outside in, we get: ∃ y P ( 1 ; y ) ∧ ∃ y P ( 2 ; y ) ∧ ∃ y P ( 3 ; y ) ⇔ [ P ( 1 ; 1 ) ∨ P ( 1 ; 2 ) ∨ P ( 1 ; 3 ) ] ∧ [ P ( 2 ; 1 ) ∨ P ( 2 ; 2 ) ∨ P ( 2 ; 3 ) ] ∧ [ P ( 3 ; 1 ) ∨ P ( 3 ; 2 ) ∨ P ( 3 ; 3 ) ]
40
English to symbolsóI
Let U = f all EIU students g, and F ( x ) : x speaks French uently C ( x ) : x knows C++
I (^) Someone can speak French and knows C++ ∃ x ( F ( x ) ∧ C ( x ))
I (^) Someone speaks French, but doesn't know C++
I (^) Everyone can either speak French or knows C++
I (^) No one speaks French or knows C++
I (^) If a student knows C++, they can speak French
English to SymbolsóII Let U = f eegles, snurds, thingamabobs g, and F ( x ) : x is a eegle S ( x ) : x is a snurd T ( x ) : x is a thingamabob I (^) Everything is a eegle ∀ x F ( x ) ⇔ :∃ x : F ( x )
I (^) Nothing is a snurd
I (^) All eegles are snurds
I (^) Some eegles are thingamabobs
I No snurd is a thingamabob
I (^) If any eegle is a snurd then it's also a thingamabob
1.4 Sets
members
universal set, U , either specically stated or understood
43
Notation used to specify sets
I list the elements between braces ; listing an object more than once does not change the setóordering means nothing. S = f a ; b ; c ; d g = f b ; c ; a ; d ; d g
I (^) specify by predicate ; here, S contains all elements from U which make the predicate P TRUE S = f x j P ( x ) g
I (^) brace notation with ellipses ; here, the negative integers: S = f: : : ; 3 ; 2 ; 1 g
44
Common Universal Sets
I (^) R ó Real Numbers
I (^) N ó Natural or Counting Numbers: f 0 ; 1 ; 2 ; 3 ; : : : g
I (^) Z ó Integers: f: : : ; 3 ; 2 ; 1 ; 0 ; 1 ; 2 ; 3 ; : : : g
I (^) Z+^ ó Positive Integers
Notation I (^) x ∈ S ó x is a member of S , or X is an element of S I (^) x ∈= S ó x is not an element of S
45
Subsets
A ⊆ B ⇔ ∀ x j x ∈ A → x ∈ B j
members I (^) the assertion x ∈ ∅ is always FALSE, thus
I (^) ∀ x j x ∈ ∅ → x ∈ B j is always (vacuously) TRUE, therefore
I (^) ∅ is a subset of every set
I (^) Note : a set B is always a subset of itself
46
Power Set
the set A
I (^) If A = f a ; b g, then P( A ) = f∅; f a g; f b g; f a ; b gg
I (^) What is the power set of the set B = f 0 ; 1 ; 2 g?
I How many elements would P(f a ; b ; c ; d g) have?
Cardinality
in A
I (^) If the cardinality is a natural number (in N), then the set is called nite ; otherwise, it's called innite
I (^) Example : Let A = f a ; b g I (^) jf a ; b gj = 2 I (^) jP( A )j = jP(f a ; b g)j = 4 I (^) A is nite, and so is P( A )
I (^) Note : j A j = n → jP( A )j = 2 n I (^) Note : N is innite since jNj is not a natural number; it is called a transnite cardinal number I (^) Note : Sets can be both members and subsets of other sets
Examples
U = f 0 ; 1 ; 2 ; 3 ; 4 ; 5 ; 6 ; 7 ; 8 ; 9 ; 10 g
A = f 1 ; 2 ; 3 ; 4 ; 5 g and B = f 4 ; 5 ; 6 ; 7 ; 8 g
I (^) A ∪ B = f 1 ; 2 ; 3 ; 4 ; 5 ; 6 ; 7 ; 8 g
I (^) A ∩ B = f 4 ; 5 g
I (^) A = f 0 ; 6 ; 7 ; 8 ; 9 ; 10 g
I (^) B = f 0 ; 1 ; 2 ; 3 ; 9 ; 10 g
I (^) A B = f 1 ; 2 ; 3 g
I (^) B A = f 6 ; 7 ; 8 g
I (^) A ⊕ B = f 1 ; 2 ; 3 ; 6 ; 7 ; 8 g
55
Venn Diagrams
Venn Diagrams are a useful geometric visualization tool for 3 or fewer sets.
I (^) The Universal set U is a rectangular box
I (^) Each set is represented by a circle and its interior
I (^) All possible combinations of the sets must be represented
I (^) Shade the appropriate region to represent the given set operation
56
For 2 sets
For 3 sets
57
Set Identities
Set identities correspond to the logical equivalences.
Example The complement of the union is the intersection of the complements: A ∪ B = A ∩ B
To prove this statement, we need to show: ∀ x [ x ∈ A ∪ B ↔ x ∈ A ∩ B ]
To show two sets are equal , we show for all x that x is a member of one set if and only if it is a member of the other.
58
Universal Instantiation
We now apply an important rule of inference (dened later) called
Universal Instantiation
In a proof, we can eliminate the universal quantier which binds a variable if we do not assume anything about the variable other than it is an arbitrary member of the Uni- verse. We can then treat the resulting predicate as a proposition.
We say, ìLet x be arbitrary.î Then we can treat the predicates as propositions.
Assertion Reason x ∈ A ∪ B ⇔ x ∈= [ A ∪ B ] Defn of complement x ∈= A ∪ B ⇔ :[ x ∈ A ∪ B ] Defn of ∈=
⇔ :[ x ∈ A ∨ x ∈ B ] Defn of union ⇔ : x ∈ A ∧ : x ∈ B DeMorgan's Laws ⇔ x ∈= A ∧ x ∈= B Defn of ∈= ⇔ x ∈ A ∧ x ∈ B Defn of complement
⇔ x ∈ A ∩ B Defn of intersection
Hence, x ∈ A ∪ B ↔ x ∈ A ∩ B is a tautology since I (^) x was arbitrary I (^) we have used only logically equivalent assertions and denitions
Universal Generalization
We can apply another rule of inference
Universal Generalization
We can apply a universal quantier to bind a variable if we have shown the predicate to be true for all values of the variable in the Universe
and claim the assertion is true for all x , i.e.,
∀ x [ x ∈ A ∪ B ↔ x ∈ A ∩ B ]
Q.E.D. ó an abbreviation for the Latin phrase “Quod Erat Demonstrandum” ñ ìwhich was to be demonstratedî ñ used to signal the end of a proof.
61
Alternative Identity
Note: as an alternative which might be easier in some cases, use the identity: A = B ⇔ [ A ⊆ B and B ⊆ A ]
Example Show A ∩ ( B A ) = The empty set is a subset of every set. Hence, A ∩ ( B A ) ⊇
Therefore, it sufces to show A ∩ ( B A ) ⊆ or ∀ x [ x ∈ A ∩ ( B A ) → x ∈ ]
So, as before, we say ìlet x be arbitraryî
62
Now we need to show x ∈ A ∩ ( B A ) → x ∈ is a tautology. But the consequent is always false. Therefore, the antecedent had better always be false also.
63
We procede by applying the denitions:
Assertion Reason x ∈ A ∩ ( B A ) ⇔ x ∈ A ∧ x ∈ ( B A ) Defn of intersection ⇔ x ∈ A ∧ ( x ∈ B ∧ x ∈= A ) Defn of difference ⇔ ( x ∈ A ∧ x ∈= A ) ∧ x ∈ B Properties of AND ⇔ 0 ∧ x ∈ B Table 6 in textbook ⇔ 0 Domination
Hence, because P ∧ : P is always false, the implication is a tautology. The result follows by Universal Generalization. Q.E.D.
64
Indexed Collections
Let A 1 ; A 2 ; : : : ; An be an indexed collection of sets. Union and intersection are associative (because AND nad OR are), we have: (^) ⋃ n i = 1 Ai^ =^ A^1 ∪^ A^2 ∪^ ^ ∪^ An and ⋂ n i = 1 Ai^ =^ A 1 ∩^ A 2 ∩^ ^ ∩^ An
Examples Let Ai = [ i ; 1 ); 1 i < 1 ⋃ n i = 1 Ai^ =^ [1;^1 ) ⋂ n i = 1 Ai^ =^ [ n ;^1 )
1.6 Functions
(mapping, map) f from A to B , denoted f : A → B , is a subset of A B such that ∀ x [ x ∈ A → ∃ y [ y ∈ B ∧ < x ; y > ∈ f ]]
and
[ < x ; y 1 > ∈ f ∧ < x ; y 2 > ∈ f ] → y 1 = y 2
I (^) Note: f associates with each x in A one and only one y in B.
I (^) A is called the domain of f
I (^) B is called the codomain of f
Example IV
73
Cardinality
I (^) Note : whenever there is a bijection from A to B , the two sets must have the same number of elements or the same cardinality
I That will become our denition, especially for innite sets.
Let A = B = R, the reals Determine which are injections, surjections, bijections: I (^) f ( x ) = x I (^) f ( x ) = x^2 I (^) f ( x ) = x^3 I (^) f ( x ) = j x j
74
Let E be the set of even nonnegative integers, f 0 ; 2 ; 4 ; 6 ; : : : g
Then there is a bijection f from N to E , the even nonnegative integers, dened by: f ( x ) = 2 x
Hence, the set of even nonnegative integers has the same cardinality as the set of natural numbers...
OH, NO! IT CAN'T BE... E is only half as big!!
75
Inverse Functions
B. Then the inverse of f , denoted f ^1 , is the function from B to A dened as:
f ^1 ( y ) = x IFF f ( x ) = y
I (^) Note: no inverse exists unless f is a bijection.
76
Example Let f be dened by the diagram ñ
X Y
A (^) B a b c d
W
V
f
Then f ^1 is dened as ñ
X Y
A B a b c d
W
V
f −
Inverse Applied to a Subset
subset of B. Then f ^1 ( S ) = f x j f ( x ) ∈ S g
I (^) Example: Let f be the following function ñ
Y Z
X
A (^) B a b c d
f
f ^1 (f Z g) = f c ; d g
f ^1 (f X ; Y g) = f a ; b g
Composition
composition of f with g , denoted f ◦ g , is the function from A to C dened by f ◦ g ( x ) = f ( g ( x ))
I (^) Example:
X Y
A (^) B a b c d
W
V
g
H I
J
f C a b c d
H
I
J
A f g C
79
Another Example
Let f ( x ) = x^2 and g ( x ) = 2 x + 1
Then f ◦ g ( x ) = ( 2 x + 1 )^2 = 4 x^2 + 4 x + 1
And g ◦ f ( x ) = 2 x^2 + 1
80
Discussion
I (^) Suppose f : B → C , g : A → B , and f ◦ g is injective
I What can we say about f and g?
I (^) Using the denition of injective , we know that if a 6 = b , then f ( g ( a )) 6 = f ( g ( b )) f , since the composition is injective I (^) Since f is a function, it cannot be the case that g ( a ) = g ( b ), since f would have two different images for the same point. I (^) Hence, g ( a ) 6 = g ( b )
I (^) It follows that g must be an injection
I (^) However, f need not be an injection... how could you show this?
81
FLOOR and CEILING Functions
f ( x ) = b x c or f ( x ) = FLOOR( x )
is the largest integer less than or equal to x.
f ( x ) = d x e or f ( x ) = CEILING( x )
is the smallest integer greater than or equal to x.
I (^) Examples: b 3 : 5 c = 3 ; d 3 : 5 e = 4
I (^) Note: The FLOOR function is equivalent to truncation for positive numbers
82
1.7 Sequences, Summations, and Cardinality of Innite Sets
the natural numbers (usually of the form f 0 ; 1 ; 2 ; : : : g to a set S
I (^) The sets f 0 ; 1 ; 2 ; 3 ; : : : ; k g and f 1 ; 2 ; 3 ; : : : ; k g are called initial segments of N
I Notation: if f is a function from f 0 ; 1 ; 2 ; : : : g to S , we usually denote f ( i ) by ai and we write: f a 0 ; a 1 ; a 2 ; a 3 ; : : : g = f ai g ki = 0 = f ai g k 0 where k is the upper limit (usually 1 )
Sequence Examples
I (^) Using zeroñorigin indexing, if f ( i ) = (^) ( i +^11 ) , then the sequence
f = f 1 ; 21 ; 31 ; 41 ; : : : g = f a 0 ; a 1 ; a 2 ; a 3 ; : : : g
I (^) Using oneñorigin indexing, the sequence f becomes
f = f 21 ; 31 ; 41 ; : : : g = f a 1 ; a 2 ; a 3 ; : : : g
Note : with innite sets, proper subsets can have the same cardinality. This cannot happen with nite sets
Countability carries with it the implication that there is a listing of the elements of the set
Denition : j A j j B j if there is an injection from A to B.
Theorem. If j A j j B j and j B j j A j, then j A j = j B j. This implies I (^) if there is an injection from A to B and I (^) if there is an injection from B to A
then I (^) there must be a bijection from A to B
91
I (^) This is difcult to prove, but is an example of demonstrating existence without construction.
I (^) It is often easier to build the injections and then conclude the bijection exists.
I (^) Example I. Theorem : If A is a subset of B , then j A j j B j. Proof: the function f ( x ) = x is an injection from A to B
I (^) Example II. jf 0 ; 2 ; 5 gj ℵ 0 The injection f f 0 ; 2 ; 5 g → N dened by f ( x ) = x is:
92
Some Countably Innite Sets
I (^) The set of even integers E is countably innite... Note that E is a proper subset of N
Proof: Let f ( x ) = 2 x. Then f is a bijection from N to E
I (^) Z+, the set of positive integers is countably innite
I (^) The set of positive rational numbers, Q+, is countably innite
93
Proof: Q+^ is countably innite
I (^) Z+^ is a subset of Q+, so jZ+j = ℵ 0 jQ+j
I (^) Next, we must show that jQ+j ℵ 0.
I (^) To do this, we show that the positive rational numbers with repetitions, QR, is countably innite.
I (^) Then, since Q+^ is a subset of QR, it follows that jQ+j ℵ 0 , and hence jQ+j = ℵ 0
94
x y 1 2 3 4 5 6 7 1 2 3 4 5
2 1 3 1 4 1 5 1 6 1 7 1 1 1 2 2 3 2 4 2 5 2 6 2 7 2 1 2 2 3 3 3 4 3 5 3 6 7 3 1 3 2 4 3 4 4 4 5 4 6 4 7 4 1 4 2 5 3 5 4 5
5 5 6 5 7 5 1 5
3
6
I (^) The position on the path (listing) indicates the image of the bijection function f from N to QR: f ( 0 ) = 11 , f ( 1 ) = 12 , f ( 2 ) = 21 , f ( 3 ) = 31 , etc.
I (^) Every rational number appears on the list at least once, some many times (repetitions).
I (^) Hence, jNj = jQRj = ℵ 0
More Examples of Countably Innite
I (^) The set of all rational numbers, Q, positive and negative, is countably innite.
I (^) The set of (nite length) strings S over a nite alphabet A is countably innite. To show this, we assume that: I (^) A is nonñvoid I (^) There is an ìalphabeticalî ordering of the symbols in A
Proof: List the strings in lexicographic order ó I (^) all the strings of zero length I (^) then all the strings of length 1 in alphabetical order, I (^) then all the strings of length 2 in alphabetical order, I (^) etc. This implies a bijection from N to the list of strings and hence it is a countably innite set
String Example
Let A = f a ; b ; c g
Then the lexicographic ordering of A is:
f; a ; b ; c ; aa ; ab ; ac ; ba ; bb ; bc ; ca ; cb ; cc ; aaa ; aab ; aac ; aba ; : : : g
= f f ( 0 ); f ( 1 ); f ( 2 ); f ( 3 ); f ( 4 ); : : : g
97
The Set of All C++ Programs is countable Proof : Let S be the set of legitimate characters which can appear in a C++ program. I (^) A C++ compiler will determine if an input program is a syntactically correct C++ program (the program doesn't have to do anything useful).
I (^) Use the lexicographic ordering of S and feed the strings into the compiler.
I (^) If the compiler says YES, this is a syntactically correct C++ program, we add the program to the list.
I (^) Else, we move on to the next string In this way we construct a list or an implied bijection from N to the set of C++ programs.
Hence, the set of C++ programs is countable. 98
Cantor Diagonalization
An important technique used to construct an object which is not a member of a countable set of objets with (possibly) innite descriptions
Theorem : The set of real numbers between 0 and 1 is uncountable.
Proof : We assume that it is countable and derive a contradiction.
If the set is countable, we can list all the real numbers (i.e., there is a bijection from a subset of N to the set).
99
We show that no matter what list you produce we can construct a real number between 0 and 1 which is not in the list.
Hence, the number we constructed cannot exist in the list and therefore the set is not countable.
It's actually much bigger than countable ó it's said to have
100
Represent each real number in the list using its decimal expansion
1
If there is more than one expansion for a number, it doesn't matter as long as our construction takes this into account.
The resulting list:
Note: choosing 0 and 9 is not a good idea because of the nonñuniqueness of decimal expansions.
Then x is not equal to any number in the list.
Hence, no such list can exist, and thus the interval ( 0 ; 1 ) is uncountable.
Proving Asymptotic Domination
time
k
g(x)
f(x)
size of input
To prove f ∈ O ( g ), given f and g : I (^) Determine / choose some positive k
I (^) Determine / choose a positive C (may depend upon choice of k )
I Once k and C are chosen, the implication must be proven true 109
Three Important Complexity Classes
Bounds from above
Growth rates equivalent
Bounds from below
Big − Oh
Theta
Big − Omega
Omega Man 110
Complexity Classes
The sets O ( g ), o ( g ), Ω( g ), !( g ), and Θ( g ) are called
dominates.
f is O ( g ) means f ∈ O ( g )
We say f ∈ Ω( g ) if there are positive constants k and C such that F ( n ) Cg ( n ) whenever n > k
If f ∈ O ( g ) and f ∈ Ω( g ), then f ∈ Θ( g )
We use îlittle-ohî and îlittleñomegaî when we have strict inequality
111
Example
Let f ( n ) = 4 n + 5 and g ( n ) = n^2. We wish to show that f ∈ O ( g )
We need to nd k and C , and show the implication
∀ n > k ; f ( n ) Cg ( n )
is true for the values we choose.
To nd k , we can set the functions equal, and solve for n :
4 n + 5 = n^2 0 = n^2 4 n 5 0 = ( n 5 )( n + 1 )
So, n = 5 or n = 1 : : : but n is the size of input and therefore cannot be negative. Thus, k must be at least 5.
112
If we choose K = 6, then C can be any positive number greater than or equal to 1.
All that is left is the proof that ∀ n > k ; f ( n ) Cg ( n ), which we shall revisit when we discuss induction proofs.
BigñOh Properties
I (^) f is O ( g ) IFF O ( f ) ⊆ O ( g )
I If f ∈ O ( g ) and g ∈ O ( f ), then O ( f ) = O ( g )
I (^) The set O ( g ) is closed under addition : If f ∈ O ( g ) and h ∈ O ( g ), then f + h ∈ O ( g )
I (^) O ( g ) is closed under multiplication by a scalar a ∈ R:
If f ∈ O ( g ) then af ∈ O ( g ) I.e., O ( g ) is a vector space
I (^) Also, as you would expect, If f ∈ O ( g ) and g ∈ O ( h ), then f ∈ O ( h )
In particular, O ( f ) ⊆ O ( g ) ⊆ O ( h )
115
Theorem
If f 1 ∈ O ( g 1 ) and f 2 ∈ O ( g 2 ), then:
116
Functional Values for Small n
log 2 n
n n n^2 2 n^ n! nn
117
Approximate Functional Values for Powers of n
log 2 n √ n n n^2 2 n^ n! nn 3.32 3.16 101 102 1024 3 : 63 ( 106 ) 1010 6.64 10 102 104 1 : 27 ( 1030 ) 9 : 3 ( 10157 ) 10200 9.97 31.62 103 106 1 : 07 ( 10301 ) 4 ( 102567 ) 103000 13.29 100 104 108 2 ( 103010 ) 2 : 9 ( 1035 ;^659 ) 1040 ;^000 16.61 316.2 105 1010 1030 ;^103 2 : 9 ( 10456 ;^573 ) 10500 ;^000 19.93 1000 106 1012 10301 ;^030 8 : 3 ( 105 ;^565 ;^708 1060 ;^000 ;^000 39.86 106 1012 1024 BIG LARGE HUGE
118
Important Complexity Classes
Theorem. The hierarchy of several familiar sequences in the sense that each sequence is BigñOh of any sequence to its right:
1 ; log 2 n ; : : : ; 4 √ n ; 3 √ n ; √ n ; n ; n log 2 n ; n √ n ; n^2 ; n^3 ; n^4 ; : : : ; 2 n^ ; n !; nn
Similarly, stated in set notation:
O ( c ) ⊆ O (log n ) ⊆ O ( n ) ⊆ O ( n log n ) ⊆ O ( n^2 ) ⊆ O ( nj^ ) ⊆ O ( cn^ ) ⊆ O ( n !)
where j > 2 and c > 1
Time Equivalencies