Professional Documents
Culture Documents
Mathematics -
CS218
4th Edition
Study Guide
1998 by International Division
Informatics Holdings Ltd
A Member of Informatics Group
Informatics Building
5 International Business Park
Singapore 609914
All rights reserved. No part of this publication may be reproduced, stored in a retrieval system,
or transmitted by any forms or means, electronic, mechanical, photocopying, recording, or
otherwise, without prior written permission of the publisher.
Every precaution has been taken by the publisher and author(s) in the preparation of this
study guide. The publisher offers no warranties or representations, nor does it accept any
liabilities with respect to the use of any information or examples contained herein.
All brands names and company names mentioned in this study guide are protected by their
respective trademarks and are hereby acknowledged.
The developer is wholly responsible for the contents, errors and omission.
As there is no assignment for Discrete Mathematics, you will need to do some problems on
your own. The exercises provided at the end of each chapter for you are there for you to develop
your skills. These problems have been selected as they give a fair representation of the type of
problems you will be facing on both the progress tests and the exam paper.
As you work on the problems for each chapter please remember to follow the concepts you
have learned in class, in some cases there are alternative ways to construct or even do the
problems; however, they may not be acceptable on the exam paper. Follow the methods used
in this study guide as they will be always be acceptable.
Show all your work, as the only representative of your work is what you have written. You will
not have an opportunity to explain what you meant, you will be graded on what you have
written on the exam paper only, if you fail to write it you will not receive the marks. If what you
write as an answer is not clear, you will not receive the marks.
Understand there is a lot of material now in this study guide. The reason for this is so you will
not have to go source for material outside this guide. It is very difficult to learn mathematics
and apply it correctly if you don’t have a good foundation. This guide will now provide you with
that foundation.
It is important that you attend every class, as each class covers a new topic, and all topics will
be covered in depth on the progress tests and exam paper. Each topic is separate from the
other topics, learning one chapter does not mean you will have a better understanding of
another chapter. Most chapters have little if anything to do with one another, however, all the
concepts presented here are relevant to computer science.
As you start your study of Discrete Mathematics please use the following conventions for each
chapter:
Chap ter 1:
When constructing a truth table, use only T for true and F for false. You must start the truth
table (start of the columns) with T’s. When constructing arguments, If . . . means implies all
the time, at times it is not clear if you should be using and or implies in constructing the
argument, try to remember this, if you can insert the word ‘and’ in the sentence and not
change the meaning of the sentence (still have a sentence that makes sense) then use and
otherwise use implies (→).
Chap ter 2:
Follow the notation used in this study guide only. Do not make up your own or use some
notation you learned in your previous studies. Use only the symbols that in the table on pg.
2-14, other symbols may be acceptable in other places but will not be acceptable on the exam
paper.
Chap ter 3:
It is important you understand the concepts presented here. Be careful to prove something
fully. For example graphing a relation to show it is a function, does not in itself prove that it i s,
you must state why it is, or is not a function after graphing it. The same applies to determining
if a function is 1− 1or onto, graphing them does not prove they are 1− 1or onto, you must state if
they are and why.
Chap ter 4:
There is a lot of material in this chapter. With summation follow the notation. Practice all the
different types of proofing methods. Induction is a very important proofing method and so
make sure you understand it very well. Follow the examples in the study guide when you
attempt to prove a problem using induction, as this is the format that will be looked for on the
exam. When proving something do not attempt to prove the right side half way and then prove
the left side to that point. Doing this will only get you only the marks for the first part of your
proof (provided the first part of your proof is correct).
Chap ter 5:
With combinatorics you need to determine what type of formula should be used. Try to be
familiar with all the different types.
Chap ter 6:
Probability is an important concept, and it does require practice as many of the concepts can
be confusing.
Chap ter 7:
Graph theory is another important concept. When labelling bipartite graphs, use the labelling
convention stated on page 7-11, other type of labelling will not be accepted.
Chap ter 8:
This chapter finishes up your study of Discrete Mathematics, covering in more depth
matrices. This is just a brief introduction to matrices, more of a review of the basic concepts of
matrices that you may use in discrete mathematics.
Table of Contents
i
Ta ble of Con tents CS218
ii
MA214 Ta ble of Con tents
iii
Ta ble of Con tents CS218
iv
CS218 Ta ble of Con tents
v
Ta ble of Con tents CS218
vi
CS218 Ta ble of Con tents
GLOSSARY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-1
vii
CHAPTER 1: INTRODUCTION TO LOGIC
Chapter Objectives
§ about the five basic logic connectives and there truth tables;
1-1
CHAPTER 1: INTRODUCTION TO LOGIC CS218
u Logic is the study of the principles and methods used in distinguishing valid
arguments from those that are invalid. Logic is also known as propositional
calculus.
u The basic building block in logic is the statement, also referred to as a proposition. A
statement is a declarative sentence which can only be either true or false.
u Clearly example 1 is true, while examples 2, and 4 are clearly false. Whether examples
3, 5 are true is not certain, but only because of our lack of knowledge, while whether
example 6 is true or false depends on the time the statement is made.
u Since a statement can only be true or false, the values of a statement can be
represented by a truth table. Using the variables p and q to represent statements, and
letting T and F stand for true and false respectively yields table 1, a truth table.
Table 1
p ~p
T F
F T
1-2
CS218 CHAPTER 1: INTRODUCTION TO LOGIC
1.2.1 CONJUNCTION
u Any two statements can be combined by the word “and” to form a composite
statement which is called the conjunction of the original statements.
p q p∧q
T T T
T F F
F T F
F F F
u If p is true and q is true then p ∧ q is true; otherwise p ∧ q is false. In other words, the
conjunction of two statements is true only if each component is true.
u Since only example 12 contains two simple statements that are true, and the others
all contain simple statements in which at least one of them is false only example 12 is
true.
1-3
CHAPTER 1: INTRODUCTION TO LOGIC CS218
1.2.2 DISJUNCTION
u Any two statements can be combined by the word “or” (in the sense of “and/or”,
called the “inclusive or”), to form a new statement which is called the disjunction
of the original two statements.
p q p ∨q
T T T
T F T
F T T
F F F
u Only example 19 is false. Each of the other compound statements is true since at least
one of its simple statements is true.
1.2.3 NEGATION
u Given any statement p, another statement, called the negation of p, can be formed
by writing “It is false that . . .” before p or, if possible, by inserting in p the word “not”.
p ~p
T F
F T
u If p is true then ~p is false; if p is false, then ~ p is true. In other words, the truth value
of the negation of a statement is always the opposite of the truth value of the original
statement.
1-4
CS218 CHAPTER 1: INTRODUCTION TO LOGIC
1.2.4 CONDITIONAL
p q p→q
T T T
T F F
F T T
F F T
u The conditional p → q is true unless p is true and q is false. In other words p → q states
that a true statement cannot imply a false statement.
u By the conditional p → q only example 23 is false. But how can this be as clearly
‘2 +2 = 4’ is true and ‘2 + 2 = 5’ is clearly false? This is the case as once we know that
the “if” is false we no longer care if the “that” is true or not; hence we willing accept
that the proposition is vacuously true.
1-5
CHAPTER 1: INTRODUCTION TO LOGIC CS218
1.2.5 BICONDITIONAL
p q p↔q
T T T
T F F
F T F
F F T
u If p and q have the same truth value, thenp ↔ q is true; if p and q have opposite truth
values, then p ↔ q is false.
u By the conditional p ↔ q examples 26 and 29 are true, while examples 27 and 28 are
false.
u By repetitive use of the logical connectives (∧, ∨, ~, →, and, ↔), we can construct
compound statements that are more involved. In the case where the substatements
p, q, . . . of a compound statement P( p , q ,...), are variables, the compound statement is
called a proposition.
u The truth value of a proposition depends exclusively upon the truth values of its
variables, that is, the truth value of a proposition is known once the truth values of its
variables are known. A simple concise way to show this relationship is through a
truth table.
p q ~q p ∧ ~q ~(p ∧ ~q)
T T F F T
T F T T F
F T F F T
F F T F T
1-6
CS218 CHAPTER 1: INTRODUCTION TO LOGIC
u Observe that the first columns of the table are for the variables p, q, . . . and there are
enough rows in the table to allow for all possible combinations of T and F for these
variables, i.e., the number of rows = 2 n
u There is then a column for each “elementary” stage of the construction of the
proposition, the truth value at each step being determined from the previous stages
by the definitions of the connectives ∧, ∨, ~
u Finally we obtain truth value of the proposition, which appears in the last column.
p q ~(p ∧ ~q)
T T T
T F F
F T T
F F T
The other columns in example 30 are used only to construct the truth table.
p q p → q q → p (p → q) ∧ (q → p)
T T T T T
T F F T F
F T T F F
F F T T T
u In addition to the “inclusive or” (see Disjunction section 2.2.2) there is another
meaning for “or” in English called the ‘exclusive or’, which means “either one or the
other, but not both.” In Logic exclusive or is referred to as exclusive disjunction.
1-7
CHAPTER 1: INTRODUCTION TO LOGIC CS218
u In mathematics or in logic, “or” always means “inclusive or” i.e., “or” always refers
to the disjunction connective.
1.4.1 TAUTOLOGY
Example 33: p ∨ ~ p is a tautology as all entries in the last column are T’s
p ~p p ∨ ~p
T F T
F T T
1.4.2 CONTRADICTION
Example 34: p ∧ ~ p is a contradiction as all entries in the last column are F’s
p ~p p ∧ ~p
T F F
F T F
1-8
CS218 CHAPTER 1: INTRODUCTION TO LOGIC
p q r p →q q → r (p → q) ∧ (q → r) p → r [(p → q) ∧ (q → r)] → (p → r)
T T T T T T T T
T T F T F F F T
T F T F T F T T
T F F F T F F T
F T T T T T T T
F T F T F F T T
F F T T T T T T
F F F T T T T T
1-9
CHAPTER 1: INTRODUCTION TO LOGIC CS218
u Since the last two columns in the truth tables are the same the statements are
logically equivalent.
a. ~ ( p ∧ q ) ≡ ~ p ∨ ~ q b. ~ ( p ∨ q ) ≡ ~ p ∧ ~ q
u DeMorgan’s Laws are an important both in logic and in set theory. The construction
of the truth tables is left as exercises.
u Example 37 is logically true since it is derivable from the tautology p ∨ ~p, where p is
‘It is raining.’
Example 38: Since ~ ( p ∧ q ) ≡ ~ p ∨ ~ q, the statement “It is not true that roses are
red and violets are blue” is logically equivalent to the statement
“Roses are not red or violets are not blue.” Where p is ‘roses are
red’, and q is ‘violets are blue.’
1 - 10
CS218 CHAPTER 1: INTRODUCTION TO LOGIC
Idempotent Laws
1a. p∨ p≡ p 1b. p∧ p≡ p
Associative Laws
2a. ( p ∨ q) ∨ r ≡ p ∨ ( q ∨ r) 2b. ( p ∧ q) ∧ r ≡ p ∧ ( q ∧ r)
Commutative Laws
3a. p∨q≡ q∨ p 3b. p∧q≡ q∧ p
4a. ( p ↔ q) ≡ ( q ↔ p)
Distributive Laws
5a. p ∨ ( q ∧ r) ≡ ( p ∨ q ) ∧ ( p ∨ r) 5b. p ∧ ( q ∨ r) ≡ ( p ∧ q ) ∨ ( p ∧ r)
Identity Laws
6a. p∨c≡ p 6b. p∧t ≡ p
7a. p∨t ≡ t 7b. p∧c≡ c
Complement Laws
8a. p ∨~ p≡t 8b. p ∧~ p≡ f
9a. ~ t ≡ c 9b. ~ c ≡ t
Involution Law
10a. ~~ p≡ p
DeMorgan’s Laws
11a. ~ ( p ∨ q ) ≡ ~ p ∧ ~ q 11b. ~ ( p ∧ q ) ≡ ~ p ∨ ~ q
12a. ( p ∨ q) ≡ ~ ( ~ p ∧ ~ q) 12b. ( p ∧ q) ≡ ~ ( ~ p ∨ ~ q)
Contrapositive
13a. ( p → q) ≡ ( ~ q → ~ p)
Implication
14a. ( p → q) ≡ ( ~ p ∨ q) 14b. ( p → q) ≡ ~ ( p ∧ ~ q)
15a. ( p ∨ q) ≡ ( ~ p → q) 15b. ( p ∧ q) ≡ ~ ( p → ~ q)
16a. [( p → r) ∧ ( q → r)] ≡ [( p ∨ q ) → r] 16b. [( p → q) ∧ ( p → r)] ≡ [ p → ( q ∧ r)]
Equivalence
17a. ( p ↔ q) ≡ [( p → q) ∧ ( q → p)]
Exportation Law
18a. [( p ∧ q ) → r] ≡ [ p → ( q → r)]
Absorbtion Law
19a. ( p ∨ q ) ∧ ( p ∧ q ) ≡ p ∨ q 19b. ( p ∧ q ) ∧ ( p ∨ q ) ≡ p ∨ q
Reductio ad absurdum
20a. ( p → q) ≡ [( p ∧ ~ q) → c]
1 - 11
CHAPTER 1: INTRODUCTION TO LOGIC CS218
1.6 ARGUMENTS
p q p→q p ∧ (p → q) [p ∧ (p → q)] → q
T T T T T
T F F F T
F T T F T
F F T F T
p q p→q (p → q) ∧ q [(p → q) ∧ q] → p
T T T T T
T F F F T
F T T T F
F F T F T
u It should be emphasized that the validity of an argument does not depend upon the
truth values or the content of the statements appearing in the argument, but only on
the formal structure of the argument. One way to present an argument is:
l Note: The statement S below the line denotes the conclusion of the argument,
and the statements S 1 , S 2 above the line denote the premises.
1 - 12
CS218 CHAPTER 1: INTRODUCTION TO LOGIC
u Another type of argument does not differentiate between the statements and the
conclusion by the use of a line; however, you can still determine the conclusion.
(Usually it contains the word therefore, but not always).
t a m t → a a ∧ m (t → a) ∧ (a ∧ m) m ∧ t [(t → a) ∧ (a ∧ m)] → (m ∧ t)
T T T T T T T T
T T F T F F F T
T F T F F F T T
T F F F F F F T
F T T T T T F F
F T F T F F F T
F F T T F F F T
F F F T F F F T
1 - 13
CHAPTER 1: INTRODUCTION TO LOGIC CS218
Example 44: Consider the truth table below. Observe that p is true in cases (lines)
1 and 2, and in these cases p ∨ q is also true. In other words, p
logically implies p ∨ q
p q p ∨q
T T T
T F T
F T T
F F F
1 - 14
CS218 CHAPTER 1: INTRODUCTION TO LOGIC
1.8 SUMMARY
1.8.2 REMARKS
l The truth table of a proposition consists precisely of the columns under the
variables and the column under the proposition.
l If P( p , q ,...) is a tautology then ~ P ( p , q ,... ) is a contradiction, and if ~ P( p , q , r,...) is
a tautology then P( p , q , r...) is a contradiction.
l For any propositions P( p , q ,...) and Q( p , q ,...), the following statements are
equivalent: i) P( p , q ,...) logically implies Q( p , q ,...) ii) The argument
P( p , q ,...) Q( p , q ,...) is valid iii) The proposition P( p , q ,...) → Q( p , q ,...) is a
tautology.
1 - 15
CHAPTER 1: INTRODUCTION TO LOGIC CS218
1. ~(p ∨ ~q)
2. p ∧ (q ∨ s)
3. (p ∧ q) ∨ (p ∧ s)
6. (a ∧ ~b) ↔ (a ∧ b)
7. (a ∨ b) ↔ ~c
8. (a ∨ b) ∧ (a ∨ ~c) → a ∨ (b ∧ ~c)
9. (a → ~b) ↔ (b→ a ∧ b)
10. (p ∧ q) → (p ∨ ~q)
11. p ∨ ~q ↔ ~( ~p ∧ q)
12. p ∨ ~(p ∧ q)
14. (p ∧ q) → (p ∨ ~q)
16. p ∧ (~p ∧ q)
17. (p → q) ∧ ( ~q ∧ p)
18. (p ∧ q) ∧ ~ (p ∨ q)
19. (p → q) ∧ (~q ∧ p)
1 - 16
CS218 CHAPTER 1: INTRODUCTION TO LOGIC
20. p → q ≡ (~p ∨ q)
21. (p ∧ q) ∨ ~p ≡ ~p ∨ q
23. (p → q) ∨ ~p ≡ ~p ∨ q
24. ~(p ∧ q) ≡ ~p ∨ ~q
25. ~(p ∨ q) ≡ ~p ∧ ~q
26. p ∨ q , ~p q
27. p → q , q → r , ~r ~p
28. p → ~q , ~p → q ~p → r
30. If you do not get a degree, you will not get a job. You got a job therefore
you must have got a degree.
31. Tanya is either a singer or a ballerina. If she is a singer then she has a
lovely voice. If she is a ballerina then she has long legs. Tanya has lovely
voice and long legs so she is both.
32. If he does not have an explanation then he will be found guilty. He either
has an explanation or he has been framed. Therefore, if he has been
framed he will be found guilty.
u Miscellaneous Problems
34. If the statement r is a tautology, what can we say about the statement
~r?
35. Simplify the follwowing argument ~ ((~ p ∨ ~ q ) ∨ (~ p ∧ ~ q )) p∨q
1 - 17
CHAPTER 2: SET THEORY
Chapter Objectives
2-1
CHAP TER 2: SET THEORY CS218
2.1 SETS
u A set is any well-defined list, collection, or class of objects. The objects in sets can be
anything: numbers, people, letters, cities, etc. These objects are called the elements
or members of the set.
u Notice that the sets in the odd numbered examples are defined, or are actual listings
of the members of the sets; and that the sets in the even numbered examples are
defined by stating properties, or rules which state whether or not a particular object
is a member of the set.
2.1.1 NOTATION
u If a set is defined by actually listing its elements then the elements are separated by
commas and enclosed in brackets { }.
u If we define a particular set by stating the properties which its elements must satisfy
then we use a letter, usually x, to represent an arbitrary element, i.e., B = {x | x is
odd}
2-2
CS218 CHAP TER 2: SET THEORY
u If on the other hand an object x is not a member of a set A, i.e., A does not contain x as
one of its elements, then we write x ∉ A. Which is read “x is not an element of A”.
Ex er cise 1:
Ex er cise 2:
Ex er cise 3:
Ex er cise 4:
Exercise 5:
Exercise 6:
Exercise 7:
Exercise 8:
Exercise 9:
Exercise 10:
u All the sets under consideration can thought of as subsets of another set called the
universal set. The universal set is denoted by U.
2-3
CHAP TER 2: SET THEORY CS218
2.2.3 SUBSETS
u We call B a proper subset of A if, first B is a subset of A and, secondly if B is not equal
to A. We denote B is a proper subset of A as B ⊂ A
u A set which contains no elements is called an empty set, or a null set. It is denoted
by the symbol ∅.
Example 25: Let A be the set of people in the world who are older than 200 years. As
there are no people in the known world older than 200 the set A is empty.
A=∅
Example 26: Let B = {x | x 2 = 4 , x is odd}. Then B = ∅
u Two sets A and B are said to be disjoint if they have nothing in common.
Example 27: Let A = {a, b}, and B = {1, 2}, then A and B are disjoint sets.
Example 28: Let X = {a, b, c, 1}, and Y = {1, 2, 3, 4, 5}, then X and Y are not
disjoint as 1 ∈ X and 1 ∈ Y
2-4
CS218 CHAP TER 2: SET THEORY
u At times sets can be the elements of another set. It is common practice to refer to
these “sets of sets” as “family of sets” or “class of sets”. Under these circumstances,
and in order to avoid confusion, families or classes of sets are denoted with script
letters A, B, C, . . .
Example 29: The set A = {{2, 3}, {2}, {5, 6}} is a family of sets. Its members are the sets
{2, 3}, {2}, and {5, 6}
u The power set of a set X, denoted by P(X), is the set of all subsets of X.
u If a set X is finite, say X has n elements, then the power set of X can be shown to have
2 n elements.
Example 30: Let X = {0, 1}, then P(X) = {∅, {0}, {1}, {0, 1}}. Note: 2 n = 4.
Example 31: Let Y = {a, b, c}, then P(Y) = {∅, {a}, {b}, {c}, {a, b}, {a, c}, {b, c},
{a, b, c}}. Note: 2 n = 8.
u If A ⊂ B, then the disk representing A will be entirely within the disk representing B
as in Fig 1.3.1.
u If A and B are disjoint, i.e. have no elements in common, then the disk representing A
will be separated from the disk representing B as in Figure 1.3.2.
u If A and B are two arbitrary sets, it is possible that some objects are in A but not B,
some are in B but not A, some are in both A and B, and some are in neither A nor B;
hence in general we represent A and B as in Fig 1.3.3.
2-5
CHAP TER 2: SET THEORY CS218
2.3.2 UNION
u The union of sets A and B is the set of all elements which belong to A or to B or to
both.
A ∪ B is shaded
2.3.3 INTERSECTION
u The intersection of sets A and B is the set of elements which are common to A and B,
that is, those elements which belong to A and which also belong to B.
A ∩ B is shaded
2-6
CS218 CHAP TER 2: SET THEORY
2.3.4 DIFFERENCE
u The difference of sets A and B is the set of elements which belong to A but don’t
belong to B.
l Remark 10: The sets ( A − B ), A ∩ B , and ( B − A ) are mutually disjoint, that is, the
intersection of any two sets is the empty set.
A − B is shaded
2.3.5 COMPLEMENT
u The complement of a set A is the set of elements which do not belong to A, that is,
the difference of the universal set U and A
( A ∪ B ) c is shaded
Example 40: Let the universal set U be the lower case English alphabet and let
X = {a, b}. Then X c = {c, d, e, f, g, . . . y, z}
l Remark 11: A \ B = A ∩ B c or A − B = A ∩ B c
Let A = {1, 2, 4, 8, 16}, B = {2, 4, 6, 8, 10} and C = {1, 3, 7, 15}. Find the
following sets:
Ex er cise 11: A ∪ B
Ex er cise 12: A ∩ B
Ex er cise 13: A − C
Exercise 14: A ∪ ( B ∩ C )
Exercise 15: ( A ∩ B ) ∪ ( A ∩ C )
Exercise 16: C − ( B − A )
2-7
CHAP TER 2: SET THE ORY CS218
u Set A is equal to set B if they both contain the same elements, i.e., if every element in
A is in B and every element in B is also in A, then we write their equality as A = B.
2.4.2 COMPARABILITY
u Two sets A and B are said to be comparable if A ⊂ B or B ⊂ A, that is if one of the sets
is a subset of the other set.
2.4.3 CARDINALITY
2-8
CS218 CHAP TER 2: SET THEORY
2.5 PROOFS
u If three or fewer sets are involved in the given identity, we can draw a Venn diagram
for each side and verify that the sets in question are equal.
B ∩C A ∪ (B ∩ C )
A∪B A ∪C
( A ∪ B) ∩ ( A ∪ C )
A−B ( A − B) ∩ C
A ∩C Bc
(A ∩C )∩ Bc
2-9
CHAP TER 2: SET THE ORY CS218
u The following exercise illustrates how to prove a problem with a Venn diagram.
2 - 10
CS218 CHAP TER 2: SET THEORY
u In order to prove something using an algebraic law you must know some of the
important laws that apply to sets. (They have been summarized in section 2.9.1). The
procedure is to apply the law you are using, then if the law has a name to correctly
identify the law you are using to the right of the application.
Statement Reason
= A ∪ (B ∩ B c ) Distributive Law
=A Identity Law
Statement Reason
Statement Reason
u The truth tables for intersection, union, and complement are the same as those for
and, or, and not.
A B A∩B A∪B Ac
T T T T F
T F F T F
F T F T T
F F F F T
2 - 11
CHAP TER 2: SET THEORY CS218
Exercise 22: Shade in the correct regions that corresponds to the given data.
a. ( A ∩ B) ∪ C
b. A ∩ ( B − C )
c. ( A − B − C ) c
u In the diagram notice that it is broken up into four regions. The numbers are used to
indicate an area not a numerical value. Each area can be described using the set
operations we learned before.
Area 1 ≡ A−B ≡ A ∩ Bc
Area 2 ≡A∩B
Area 3 ≡ B− A ≡ B ∩ Ac
Area 4 ≡ ( A ∪ B)c ≡ Ac ∩ Bc
Area 1, 2, 3 ≡ A ∪ B
2 - 12
CS218 CHAP TER 2: SET THEORY
2.9 SUMMARY
Idempotent Laws
1a. A ∪ A = A 1b. A ∩ A = A
Associative Laws
2a. ( A ∪ B ) ∪ C = A ∪ ( B ∪ C ) 2b. ( A ∩ B ) ∩ C = A ∩ ( B ∩ C )
Commutative Laws
3a. A ∪ B = B ∪ A 3b. A ∩ B = B ∩ A
Distributive Laws
4a. A ∪ ( B ∩ C ) = ( A ∪ B ) ∩ ( A ∪ C ) 4b. A ∩ ( B ∪ C ) = ( A ∩ B ) ∪ ( A ∩ C )
Identity Laws
5a. A ∪ ∅ = A 5b. A ∩ U = A
6a. A ∪ U = U 6b. A ∩ ∅ = ∅
Involution Law
7. (A c )c = A
Complement Laws
8a. A ∪ A c = U 8b. A ∩ A c = ∅
9a. U c = ∅ 9b. ∅ c = U
10a. A ∪ B = ( A c ∩ B c )
c
10b. A c ∩ B c = ( A ∪ B ) c
Alternative Representation for Set Difference
11a. A \ B = A ∩ B c 11b. A \ B c = A ∩ B
Double Complement Law
12. ( A c ) c = A
DeMorgan’s Laws
13a. ( A ∪ B )c =A ∩B
c c
13b. ( A ∩ B ) c = A c ∪ B c
14a. X \ ( A ∪ B ) = ( X \ A ) ∩ ( X \ B ) 14b. X \ ( A ∩ B ) = ( X \ A ) ∪ ( X \ B )
Subset Laws
15a. A ∪ B ⊆ X iff A ⊆ X and B ⊆ X 15b. X ⊆ A ∩ B iff X ⊆ A and X ⊆ B
16a. A ⊆ A ∪ B and B ⊆ A ∪ B 16a. A ∩ B ⊆ A and A ∩ B ⊆ B
Absorbtion Laws
17a. A ∪ ( A ∩ B ) = A 17b. A ∩ ( A ∪ B ) = A
2 - 13
CHAP TER 2: SET THE ORY CS218
Symbols Meanings
∈ Is an element of
∉ Is not an element of
A⊂B A is a proper subset of B
A⊆S A is a subset of S
A⊄B A is not a subset of B
S ⊇ A, S ⊃A Set S is a superset of the set A
∅ Empty set
∪ Union
∩ Intersection
A − B, A \ B, A ~ B A minus B
A’ , A , A
c
A complement
A=B A and B have exactly the same elements
A≠B A and B do not have exactly the same elements
A ≡Β Equivalence; A is equivalent to B
↔, ⇔ If and only if or iff
→, ⇒ Implies
∀ For all, for every
∃ There exists
∋, |, : Such that
∞ Infinity
2.9.3 REMARKS
l A∩B=B∩ A
l ( A ∩ B ) ⊆ A and ( A ∩ B ) ⊆ B
l A \ B = A ∩ B c or A − B = A ∩ B c
2 - 14
CS218 CHAP TER 2: SET THEORY
u Draw a Venn diagram and shade in the correct regions that corresponds to the given
data:
1. A − B − C
2. ( A − B ) c
3. (A c − B c ) A B
4. ( A c − B c )
c
5. A c ∩ B c ∩ C c
6. A c ∪ B c ∪ C c
7. ( A ∩ B ) c ∪ C c
8. A ∩ B ∩ C C
9. A ∪ B ∪ C
10. ( A ∩ B ) ∪ C c
11. A ∩ B c ∩ C
12. A c ∩ B ∩ C
13. A c ∪ B ∪ C
14. A ∪ B c ∪ C
15. A ∪ B c ∪ C c
u Show by using Venn Diagrams or otherwise, whether the following identities hold:
16. ( A ∩ B ) c ≡ Ac ∪ Bc
17. A − B ≡ A ∩ Bc
18. A c ∩ B c ∩ C c ≡ ( A ∪ B ∪ C )c
19. A ∪ (B ∩ C c ) ≡ ( A ∪ B ) ∩ (A ∪ C c )
20. A ⊆ A
21. A ∪ A = U
22. A ∩ U = A
23. ∅ ⊆ A
u Suppose X = {x | x = y 2 , y ∈ N}
P = { p | p is a prime number}
E = {s | s = 2t , t ∈ N}
Determine
24. P ∩ E
25. X ∪ E
26. X ∩ P
27. E c
2 - 15
CHAP TER 2: SET THE ORY CS218
28. ( A ∩ B) ∩ C = A ∩ (B ∩ C )
29. ( A ∪ B ) ∪ C = A ∪ ( B ∪ C )
30. A \ ( A \ B ) = A ∩ B
31. A = A ∩ ( A ∪ B )
32. ( A ∩ B ) c = A c ∪ B c
33. A ∪ ( B ∩ C ) = ( A ∪ B ) ∩ ( A ∪ C )
u Determine whether each of the following statements is true or false. Then explain.
34. x ∈ {x}
35. {x} ⊆ {x}
36. {x} ∈ {x}
37. {x} ∈ {{x}}
38. ∅ ⊆ {x}
u Suppose that A is the set{a , b} and that B is the set {∅}. Write the following sets out in
full, listing their elements where possible:
u Venn diagrams
43. Draw a Venn diagram and shade the required region for the following:
i) ( A ∩ B )c ∩ C c
ii) Bc ∪ (A ∪C )
46. Show that the following argument is valid using Venn diagrams:
All bakers bake bread. All chefs bake cakes. All the chefs attended the
meeting. David bakes cakes, but did not attend the meeting. Therefore,
David is not a chef.
2 - 16
CS218 CHAPTER 2: SET THEORY
u Algebraic Laws
2 - 17
CHAPTER 3: RELATIONS AND FUNCTIONS
Chapter Objectives
3-1
CHAP TER 3: RE LA TIONS AND FUNC TIONS CS218
u An ordered pair consists of two elements, say a and b, in which one of them, say a is
designated as the first element and the other as the second element.
u Two ordered pairs (a, b) and (c, d) are equal if and only if a = c and b = d.
Example 2: The set {2, 3} is not an ordered pair since the elements 2 and 3 are
not distinguished in a set.
Example 3: Ordered pairs can have the same first and second elements such as
(1, 1), (4, 4)
u The set of all ordered pairs (a, b), where a ∈ A and b ∈Β , is called the Cartesian
Product, or simply the product set, of the two sets.
Example 5: W = {x, y}. Then W × W = {(x, x), (x, y), (y, x), (y, y)}
u Q denotes the rational numbers. The rational numbers are those real numbers which
can be expressed as the ratio of two integers. Q = x | x = { p
}
q where p ∈ Z , q ∈ Z
u Q c denotes the irrational numbers, i.e. a number that is not rational is irrational.
u R denotes the real numbers. Real numbers are the rational and irrational numbers.
3-2
CS218 CHAP TER 3: RE LA TIONS AND FUNCTIONS
u A binary relation between sets A and B is a subset of A × B. That is, a binary relation
is a collection of ordered pairs from A × B.
Example 6: Let A = {1, 2, 3} and B = {a , b}. Define some relations between A and B.
R1 = {(1, a ), ( 2, b ), ( 3, a ), (1, b )}
R2 = {( 3, b )}
R3 = A × B
R4 = ∅
u The domain of a relation R is the set of all first elements of the ordered pairs which
belong to R, and the range of R is the set of second elements.
Example 7: Let A = {1, 2, 3}, and R = {(1, 2), (1, 3), ( 3, 2)}. Then R is a relation on A
since it is a subset of A × A
Example 8: Let A = {eggs, milk, corn} and B = {cows, goats, hens}. We can
define a relation R from A to B by ( a , b ) ∈ R if a is produced by b. In
other words:
R = {(eggs, hens), (milk, cows), (milk, goats)}
With respect to this relation,
eggs R hens, milk R cows, milk R goats
Example 9: Suppose we say that two countries are adjacent if they have some
part of their boundaries in common. Then “is adjacent to” is a
relation R on the countries of the earth.
Thus:
(Malaysia, Indonesia) ∈ R, but (Indonesia, Thailand) ∉R
3-3
CHAP TER 3: RE LA TIONS AND FUNC TIONS CS218
u Relations can be represented by listing the elements, as in examples 7-9, or they can
be represented graphically, by using pictures, or by using a matrix.
u Another way of picturing a relation when it is from a finite set to itself is to write
down the elements of the set and then draw an arrow from an element x to an element
y whenever x is related to y. This type of diagram is called a directed graph of the
relation. (We will be discussing directed graphs in greater detail in chapter 7).
Example 11: The directed graph of R = {(1, 2), ( 2, 2), ( 2, 4 ), ( 3, 2), ( 3, 4 ), ( 4 , 1), ( 4 , 3)}
on the set A = {1, 2, 3, 4} is:
u We will use the following graphical representation; see example 12, to represent a
relation.
Example 12: Let A = {1, 2, 3}, and let R be the relation on A defined as
R = {(1, 2), ( 2 , 1), ( 2, 3), ( 3, 1), ( 3, 3)}. Graphically:
3-4
CS218 CHAP TER 3: RE LA TIONS AND FUNCTIONS
Exercise 4: Draw the graphical representations of the relations R1, R2, R3,
and R4 from example 6.
Exercise 5: List the ordered pairs belonging to the relation shown below:
Exercise 6: Draw the directed graph representation of the relation “less than
or equal to” on the set S 3.
Exercise 7: Draw the directed graph representation for the relation R such
that, R = {(1, 2 ), ( 2, 1), ( 2, 3), ( 3, 1), ( 3, 3)}
3-5
CHAP TER 3: RE LA TIONS AND FUNC TIONS CS218
u The more commonly used representation of relations that is also more convenient for
computations is using a matrix to represent a relation.
A = {a1 , a 2 ,... , a n}
B = {b1 , b 2 ,... , b m}
Exercise 8: Write the matrix that represents R = {( 3, 3), ( 2, 3), (1, 2), ( 3, 2)}
Example 13: Let A be the set S 3 , and let B be the set S 2 . Let R be the relation
between A and B. R = {(1, 1), (1, 2) , ( 2, 1), ( 3, 2)}. Write the matrix
representing R.
Example 14: Describe the relations corresponding to the two matrices given
below.
T F T T F T F
M1 = F T F T M 2 = T F T
T F F T T T T
For matrix M 1, there are three rows and four columns, so M 1 is a relation R1
between S 3 and S 4 . The graph of R1 is represented in (a). Matrix M 2 , which has
three rows and three columns then is a relation R 2 on the set S 3 . The graph
of M 2 is represented in (b)
3-6
CS218 CHAP TER 3: RE LA TIONS AND FUNCTIONS
3.3.1 REFLEXIVE
Example 15: The directed graph of every reflexive relation includes an arrow from
every point to the point itself, i.e.
Example 16: Let V = {1, 2, 3, 4} and R = {(1, 1), ( 2, 4 ), ( 3, 3), ( 4 , 1), ( 4 , 4 )}. Then R is not
a reflexive relation since ( 2, 2) does not belong to R
3.3.2 SYMMETRIC
a b c d a b c d a b c d
a F F F F a F T F T a F F F F
b F F T F b T F T F b F F F F
cF T F F c F T F F cF F F F
d F F F F d T F F F d F F F F
Example 18: Let S = {1, 2, 3, 4}, and let R = {(1, 3), ( 4 , 2), ( 2, 4 ), ( 2, 3), ( 3, 1)}. Then R is
not a symmetric relation since ( 2, 3) ∈ R but ( 3, 2) ∉ R
3-7
CHAP TER 3: RE LA TIONS AND FUNC TIONS CS218
3.3.3 TRANSITIVE
1. Let R be the “less than” relation on the set Z. Then R is transitive, but
not reflexive or symmetric.
If ( x, y) ∈ ∅, then ( y, x) ∈ ∅
If x ∈ S 3 , then ( x, x) ∈ ∅
3-8
CS218 CHAP TER 3: RE LA TIONS AND FUNCTIONS
3.3.4 IRREFLEXIVE
u Do not confuse the irreflexive property with the absence of the reflexive property.
There are relations that are neither reflexive nor irreflexive.
Example 22: Show that the relation on the set {a , b , c} given by the set of ordered
pairs {( a , b ), ( b , c), ( c, a )} is irreflexive.
3.3.5 ANTISYMMETRIC
u Do not confuse the antisymmetric property with the absence of the symmetric
property either. There are also relations that are neither symmetric nor
antisymmetric.
Example 23: Show that the relation “greater than or equal to” on Z is
antisymmetric.
The relation “greater than or equal to” on the set of integers is antisymmetric,
because if x, y ∈ Z , then ( x ≥ y and y ≥ x) ⇒ ( x = y)
3-9
CHAP TER 3: RE LA TIONS AND FUNC TIONS CS218
Example 25: If a and b are positive integers, a|b means that a is a divisor of b,
i.e. b = ac for some integer c. Show that “|” is a partial ordering of
the set of positive integers.
u Every relation R between sets A and B is a subset of A × B. We can reverse the roles of
A and B to obtain a relation between B and A called the inverse relation of R. The
inverse relation of R, denoted R −1, is the relation between B and A given by
R −1 = {( y, x) : ( x, y ) ∈ R}
3 - 10
CS218 CHAP TER 3: RE LA TIONS AND FUNCTIONS
u Let’s look now at how to create new relations from existing ones. Let R be a relation
between sets A and B, and let S be a relation between B and C. The composition of R
and S is the relation between A and C, denoted S o R, given by:
S o R = {(x, z) : x ∈ A , z ∈ C , ∃ y ∈ B ∋ x R y and y S z}
where ( S o R )( x) = S ( R ( x ) = S ( y ) = z, and
( S o R )( x ) = S ( R ( x )) = S ( u ) = w
u One can view the composite relation as a means of linking elements of A to elements
of C by using elements of B as intermediate points.
3 - 11
CHAP TER 3: RE LA TIONS AND FUNC TIONS CS218
Exercise 11: Let R be the relation between S 3 and S 4 , and let S be the relation
between S 4 and S 2 , (see figure below). Find the composite
relation S o R between S 3 and S 2 .
u A function is an association of exactly one object from one set (the range) with each
object from another set (the domain).
u This means that there must be at least one arrow leaving each point in the domain,
and futher that there can be no more than one arrow leaving each point in the
domain.
3 - 12
CS218 CHAP TER 3: RE LA TIONS AND FUNCTIONS
u We usually denote relations with capital letters. With functions the convention is to
use lowercase letters.
u Let f be a function from A to B. Because each element x of A appears in one and only
one pair ( x, y) ∈ f , it is possible to write y = f ( x) whenever x ∈ A. This notation
suggests mapping the element x to the element y. Functions are often referred to as
mappings or transformations.
f [ A ] = { f ( x) : x ∈ A}
1. This is not a function because (1, a) and (1, b) are both in the relation.
3. Since y − x = 1 iff y = x +1, it is easy to see that this is a function with domain
and codomain equal to the set of real numbers. Also, for each real number
y, there is a real number x such that y = x +1. Therefore, the range of the
function is the set of real numbers.
4. This is a function. The domain and codomain are both the set of positive
integers. However, if y is a positive integer, there is a positive integer x
such that y = x +1 iff y ≥ 2. Hence the range is {2, 3, . . .}
u Notice that the function in (4) is not equal to the function in (3), even though they
both have the form y = x +1
3 - 13
CHAP TER 3: RE LA TIONS AND FUNC TIONS CS218
u The set of all ordered pairs of the function f plotted in a Cartesian coordinate system
is called the graph of f.
l Remark 2: For a graph to be the graph of a function, any given vertical line can
intersect the graph in a most one point.
3 - 14
CS218 CHAP TER 3: RE LA TIONS AND FUNCTIONS
3.7.1 INJECTIONS
one-to-one function
3.7.2 SURJECTIONS
onto function
3.7.3 BIJECTIONS
u A function can also be neither 1− 1nor onto, or it can be both 1− 1and onto. If a function
is both 1− 1 and onto it is called a bijection or bijective function.
or
3 - 15
CHAP TER 3: RE LA TIONS AND FUNC TIONS CS218
or
l Remark 5: The codomain and the range are equivalent iff the function is onto.
3.8.1 LIMITS
c
l Remark 6: If n > 0, lim n = 0 for any constant c
x→+∞ x
x 3 + 3x − 1
Example 34: Find the following limit: lim
x→+∞ x + 7x + 3
2
x 3 + 3x − 1 1+ ( 3x 2 ) − ( 1x 3) 1+ 0 + 0 1
lim = lim = =
x + 7( x ) + ( x )
x→+∞ x + 7x + 3 x→+∞ ( 1 ) 0+ 0+ 0 0
2 12 3 3
3 - 16
CS218 CHAP TER 3: RE LA TIONS AND FUNCTIONS
1
l Remark 8: When the limit of a function is , we say that lim f ( x) = +∞.
0 x→+∞
5x 3 + 3x
Exercise 16: Find the lim
x→−∞ 9x − 4 x + 2
4 3
u Rather than write op( a , b ) for the value of the operation, it is more common to write
a op b , a , b ∈ A.
u Two functions are said to be equal if they have the same domain and codomain, and
for all x in the domain f ( x) = g ( x)
3 - 17
CHAP TER 3: RE LA TIONS AND FUNC TIONS CS218
s( x) = ( f + g )( x) = ( 3x + 5) + ( 4 x − 3) = 7x + 2
d ( x) = ( f − g )( x) = f ( x) − g ( x) = ( 3 x + 5) − ( 4 x − 3) = −x + 8
f ( x)
u The quotient of f and g, f g, is defined by ( f g )( x) =
g( x )
q( x) = ( f g )( x) = f ( x) g ( x) = ( 3x + 5) ( 4 x − 3)
u As functions are subsets of relations, the composition of a function is the same as for
relations.
a. ( f o g )( x) b. ( g o f )( x) c. ( f o f )( x) d. ( g o g )( x)
a. ( f o g )( x) = f ( g( x)) = f ( 4 x − 3) = 3( 4 x − 3) + 5 = 12x − 9 + 5 = 12x − 4
3 - 18
CS218 CHAP TER 3: RE LA TIONS AND FUNCTIONS
u Any function f has an inverse relation, f −1. The inverse relation does not need to be a
function. If the inverse relation of a function is a function, we say that the function is
invertible.
Therefore, f −1( x) = ( x + 1) 4
x +1
Example 44: Verify that f −1( x) = is the inverse function of f ( x) = 4 x − 1
4
x + 1 x +1
(fo f −1 )( x) = f ( f − 1( x)) = f
4
= 4⋅
4
− 1 = ( x + 1) − 1 = x and
( 4 x − 1) + 1 4 x
( f −1 o f )( x) = f −1 ( f ( x)) = f −1( 4x = 1) = 4 = 4 = x
3 - 19
CHAP TER 3: RE LA TIONS AND FUNC TIONS CS218
3.10 SUMMARY
3.10.1 THEOREMS
l Let A and B be sets. If A = n , and B = m, then A × B = nm.
3.10.2 REMARKS
l For a graph to be the graph of a function, any given vertical line can intersect the
graph in a most one point.
l A graph of a function f is 1− 1 iff any horizontal line intersects the graph in at most
one point.
l A graph of a function f is onto iff every horizontal line intersects the graph in at
least one point.
l The codomain and the range are equivalent iff the function is onto.
c
l If n > 0, lim n = 0 for any constant c
x→+∞ x
l To find the limit of a function as x approaches ∞, first divide the numerator and
denominator by the highest power of x appearing in either place and then to let x
approach ∞.
1
l When the limit of a function is , we say that lim f ( x) = +∞
0 x→+∞
3 - 20
CS218 CHAP TER 3: RE LA TIONS AND FUNCTIONS
u Let A = {1, 2, 3, 4}, and let R be the relation on A given by R = {(1, 2) , (1, 3), ( 2, 4 )}. Show
the following representation of R.
u Let A = {1, 3, 5, 9}, and let B = {u , v, w}. Represent the following relations in graphical
form.
8. R 3 = {( 5, u ), ( 5, v), ( 5, w )}
13. Find A × B × C
u Given ( 2x, x + y) = ( 6, 2)
3 - 21
CHAP TER 3: RE LA TIONS AND FUNC TIONS CS218
u L e t R a n d S b e t h e f o l l o w i n g r e l a t i o n s o n A = {1, 2, 3}:
R = {(1, 1), (1, 2), ( 2, 3), ( 3, 1), ( 3, 3)} S = {(1, 2), (1, 3), ( 2, 1), ( 3, 3)}
16. give the corresponding set of ordered pairs and the matrix
representation.
u For each of the following relation matrices, list the set of ordered pairs that belong to
the relation and draw the graph form of the relation.
1 2 3
1 2
1 2 3 4 1 T F T
17. 18. 1 F T 19.
1[T F F T] 2 T F F
2 F T
3 F T T
3 - 22
CS218 CHAP TER 3: RE LA TIONS AND FUNCTIONS
T = {(1, 1), (1, 2), ( 2, 2), ( 2, 3 )}, ∅ = empty relation, A × A = universal relation.
Determine whether or not each of the above relations on A is:
26. reflexive
27. symmetric
28. transitive
u The relations R, S, T and U are defined upon integers by the following equivalence’s:
a R b ↔ a ≥ b a S b ↔ a < b a T b ↔ a R b ∧ a S b aU b ↔ a R b ∨ a S b
u Let R be the relation on the set of positive integers, defined by a R b iff a × b is odd.
Prove the following properties hold or give a counter-example.
35. reflexivity
36. symmetry
37. transitivity
u Let R be the relation on the set of positive integers defined by a R b iff a + 2b = 10. Give a
counterexample to prove that:
3 - 23
CHAP TER 3: RE LA TIONS AND FUNC TIONS CS218
F T
T F F
u Let M 1 = T F , let M 2 =
T T T
F T
42. Compute M 1 ⋅ M 2
43. Compute M 2 ⋅ M 1
44. RoS
45. S oR
46. RoR
47. S oS
u Use the following diagrams.
49. f : R → R f ( x) = 2 x
50. f : Z → Z + f ( x) = x
51. f : Z+ → Z+ × Z+ f ( x) = ( x, x +1)
53. f ( x) = x
54. g ( x) = x 3 + 1
55. h( x) = 3x − 1
56. f ( x) = 4 x − 1
57. g ( x) = x 3 + 1
3 - 24
CS218 CHAP TER 3: RE LA TIONS AND FUNCTIONS
u The functions f and g are both injective and surjective functions upon integers. The
functions h and i are defined by the following equalities: h = f o g , i = ( g −1 ) o ( f −1 )
63. f ( x) = x +1 g ( x) = x −1
x2
67. lim x −
x→+∞ x +1
5x 3 + 1
68. lim
x→+∞ 2x + 3
3
u A relation maps elements from set A to set B. A has m elements, and B has n elements.
How many one-to-one functions are there if:
69. m= n ?
70. m> n ?
71. m< n ?
u The following functions are defined on the integers. State whether they are
one-to-one, onto, or bijective functions, and explain your reasons in each case.
72. f (x ) = x 2
73. g (x ) = x 3 − x
74. g (x ) = x 2 −1
2x − 3
75. h( x ) = , where x ≠ 5
7
5x − 7
3 - 25
CHAP TER 3: RE LA TIONS AND FUNC TIONS CS218
u Relations and functions can both be seen as sets of pairs. The presence of the pair
( x, y ) in the relation (or function) indicates that x is related to y (or that x maps to y
under the function).
u Suppose that A is the set {1, 2, 3} and that B is the set {a , b , c, d }, with four distinct
elements:
u Since functions may be seen as a special case of relations, we may apply the terms
reflexive, symmetric, and transitive to functions, with the same meaning as before. If
F, G, and H are functions from {1, 2, 3} to {1, 2, 3}, what must be true if
82. F is reflexive?
83. G is symmetric?
84. H is a transitive, onto function?
85. g (x ) = x 2 −1
2x − 3
86. h( x ) = where x ≠ 75
5x − 7
u The following functions are defined on the integers. State whether they are
one-to-one, onto, or bijective functions, and explain your reasons in each case.
87. f (x ) = x 2
88. g (x ) = x 3 − x
u Using the relation that holds between two integers a and b if and only if a divides b
with no remainder.
3 - 26
CS218 CHAP TER 3: RE LA TIONS AND FUNC TIONS
92. Which pairs would you need to add to R to make a reflexive relation?
93. Which pairs would you need to add to R to make a transitive relation?
u Relations
94. Consider the circle relation C defined for all ( x, y ) ∈ R × R, such that
−
1 ≤ x, y ≤ 1 ( x, y ) ∈ C ↔ x 2 + y 2 = 1. Is C a function? Explain.
95. Consider the relation L defined for all ( x, y ) ∈ R × R ( x, y ) ∈ L ↔ y = x −1 Is
L a function? Explain.
i) reflexive?
ii) symmetric
iii) transitive?
iv) an equivalence relation?
In each case explain your answers.
97. Consider the relation R represented by the following matrix
V1 V2 V3
V1 1 1 0
V2 1 1 1
V3 0 1 1
Is the relation
i) reflexive?
ii) symmetric?
iii) transitive?
iv) an equivalence relation?
In each case explain your answers.
u Suppose that R and S are binary relations on a set A. Answer the following, and give
explanations for your answers.
u Consider the circle relation on the set of real numbers: for all
x, y ∈ R , x C y ↔ x 2 + y 2 = 1. Determine if each of the following is true, and justify
your answers.
101. C is reflexive
102. C is symmetric
103. C is transitive.
3 - 27
CHAP TER 3: RE LA TIONS AND FUNC TIONS CS218
105. Show that if both f and g are one-to-one functions, then f o g is also one-
to-one.
106. Show that if both f and g are onto functions, then f o g is also onto.
3 - 28
CHAPTER 4: METHODS OF PROOFS
Chapter Objectives
4-1
CHAP TER 4: METH ODS OF PROOFS CS218
u Before we continue, you must be familiar with a few basic mathematical facts.
u We have been using the “Quantifiers” ∀ and ∃ so far without formally introducing
them to you. They are known as predicate quantifiers. ∀ means for all and ∃
means there exists.
Example 1: If we have one computer that all students must share, we say:
Note: The two example may both appear to be saying that “there exists” only one
computer; however, example 2 is actually saying mathematically that every
student has a ‘unique’ computer.
−
4= ( 4) = 4 and 4 = 4
− −
4.1.4 DIVISIBILITY
u If a divides b, we write a | b.
4-2
CS218 CHAPTER 4: METHODS OF PROOFS
u There are several different types of numbers which you need to be aware of. They are:
a. Prime numbers: Prime numbers are numbers that are divisible by 1 and
the number itself, i.e. 2, 3, 5, 7, 11, 13, 17, 19, 23, . . .
−
b. Integers: Any of the numbers . . . , 4 , − 3, − 2, − 1, 0, 1, 2, 3, . . .
Exercise 1: Find the first six terms of the sequence satisfying the recurrence
relation: x1 = 2 x2 = 1 x n+2 = 3xn − 2xn+1.
4.1.7 SEQUENCES
u A sequence is simply a list, such as 2, 4, 6, . . . where the numbers 2, 4, etc. are the
terms of the sequence.
u A geometric sequence is a sequence for which the ratio of a term to its predecessor
is the same for all terms. The general form of a finite geometric sequence is
{a , ar, ar 2 , ar 3 ,L , ar n−1}, where a is the first term, r is the common ratio, and ar n−1 is
a (1− r n )
the last term. The sum of the terms is
1− r
4-3
CHAPTER 4: METHODS OF PROOFS CS218
a
l Remark 1: S∞ = represents a geometric sequence summed to infinity,
1− r
where a is the first term, and r is the common ratio.
a − r n+1 a
Exercise 3: Show that S n = = as n goes to infinity when |r| < 1
1− r 1− r
a
3. Plug the values into the geometric sequence equation S ∞ =
1− r
4.1.8 SERIES
n
u A series can be written in the form a 1 + a 2 + a 3 + ... + a n + ..., or as ∑ a . The symbol
i
i =1
∑ ai means summation; read “the sum i equals 1 to n of a sub i”. The starting value
is the value on the bottom of the symbol ∑; the ending value is placed on top of the ∑
symbol.
5
Example 8: Write the sum ∑ ( 2i + 1) out in full.
i =1
∑ ( 2i + 1) = [ 2(1) + 1] + [ 2( 2) + 1] + [ 2( 3) + 1] + [ 2( 4) + 1] + [ 2( 5) + 1]
i =1
= [ 2 + 1] + [ 4 + 1] + [ 6 + 1] + [ 8 + 1] + [10 + 1] = 3 + 5 + 7 + 9 + 11.
k k+1
Example 9: The series 1+ 2 + 3 + L + k + k + 1 = ∑ i + ( k + 1) = ∑ i
i =1 i =1
k+1 k
Example 10: The summation ∑ i = ∑ i + ( k + 1)
i =1 i =1
4-4
CS218 CHAPTER 4: METHODS OF PROOFS
Summation Properties
b b+k
1. ∑ i = ∑ (i − k) k ∈N
i=a i = a+k
b b −k
2. ∑ i = ∑ (i + k )
i=a i=a −k
k ∈N
b b
3. ∑ cx i = c∑ x i c is a constant , xi is an expression invo lving i.
i=a i=a
b b b
4. ∑ (x
i=a
i + y i ) = ∑ xi + ∑ yi
i=a i=a
x i and y i are expressions involving i.
n
5. ∑ c = nc c is a constant.
i =1
a
6. ∑x i = xa xi is an expression involving i.
i=a
4.1.9 EXPONENTS
u The rules for exponents that you will need to be familiar with are summarized in the
following table.
The Rules of
Exponents
x n ⋅ x m = x n+m
xn
= x n− m
xm
(x n ) m = x nm
x 0 = 1, x ≠ 0
1
x −n =
xn
( xy) n = x n ⋅ y n
n
x xn
= n
y y
4-5
CHAPTER 4: METHODS OF PROOFS CS218
4.1.10 LOGIC
u The inverse of p → q is ~ p → ~ q
u The converse of p → q is q → p
u The contrapositive of p → q is ~ q → ~ p
l Remark 3: p → q ≡ ~ q → ~ p
Exercise 5: State the inverse, the converse, and the contrapositive of: If x is
odd, then x 2 is odd.
inverse:
converse:
contrapositive:
Exercise 6: State the inverse, the converse, and the contrapositive of: He’s 60,
if he’s a day.
inverse:
converse:
contrapositive:
4.2 PROOFS
u Now that we have established the basic tools for propositions and predicates we can
use them to construct logic arguments. There are several ways in mathematics to
construct a logical argument. A logical argument is the same thing as a proof.
u Direct arguments are probably familiar to you from algebra and plane geometry. Let
us look a direct proof to show you again what one is:
Example 11: Give a direct proof for “If x > y then x 2 > y 2 .”
2
We first observe that x 2 > y , since x > y. Also z 2 = z 2 for any number z. The
conclusion follows.
Example 12: Give a direct proof that for real numbers x and y, x + y ≥ x + y .
Use the fact that for any real number z, z 2 = z . For any real numbers x and
2
4-6
CS218 CHAPTER 4: METHODS OF PROOFS
u The second kind of argument, contrapositive, is based on the fact that not Q ⇒ not
P is logically equivalent to P ⇒ Q i.e. ( ~ q → ~ p ) ↔ ( p → q ).
Let P( n ) be the statement “n is a prime number different from 2,” and let
Q( n ) be the statement “n is odd.” To carry out the proof by contradiction, we
need to assume that n is a prime number different from 2 and that n is even.
Then if we find a contradiction, the proof is complete. From the assumption,
we see that n = 2 ⋅ p for some positive integer p. If p = 1, then n = 2. If p > 1, then n
is not prime because n is divisible by p and p ≠ n or p ≠ 1. In both cases, we
obtain a contradiction, so the initial implication is true.
b b b
2
a
⇒ 2 = 2 2 b 2 = a 2 which implies a 2 is even. If a 2 is even then a is also even, and
b
so a = 2 p ⇒ a 2 = 4 p 2 ⇒ 4 p 2 = 2b 2 ⇒ b 2 = 2 p 2 . Hence b 2 is also even, and so b is
also even. However if both a and b are even then they both have a common
factor and are not in lowest terms, so we have a contradiction, and thus the
initial implication is true.
4-7
CHAPTER 4: METHODS OF PROOFS CS218
4.2.4 COUNTEREXAMPLES
u At times use of proofs is not only impossible, but unnecessary. Sometimes in order to
prove something all that is necessary is to provide an example that proves the
statement false, i.e. a counterexample.
u Before mathematical induction can be applied it is necessary that the different cases
of the law depend upon a parameter which takes on the values 1, 2, 3,L
(2) Prove that if the theorem is true for the n th case (or for the first through
nth cases), then it is true for the ( n +1)th case.
u If there were a case for which it is not true, there must be a first case for which it is not
true. Because of (1), this is not the first case. But because of (2), it cannot be any other
case [since the previous case could not be true without the next case (known to be
false) being true; it could not be false because the next case is the false case].
u Mathematical induction is useful for proving propositions that must be true for all
integers or for a range of integers.
u The statement P( n ) is called the inductive hypothesis, condition (1) is called the
base step, and condition (2) is called the induction step.
u When proving something using induction you need to be sure to check that both
condition (1) and condition (2) are satisfied.
4-8
CS218 CHAPTER 4: METHODS OF PROOFS
n
Example 17: Prove ∑ ( 2 i − 1) = n 2 is true using mathematical induction.
i =1
1
Step 1: Prove for P(1). P(1) = ∑ ( 2i − 1) = 2( 1) − 1 = 2 − 1 = 1= 12 . So we have
i =1
shown this to be true for P(1).
k
Step 2: Assume that P( k ) is true, i.e. that P( k ) = ∑ ( 2i − 1) = k 2 is true.
i =1
k+1
Prove that P( k +1), i.e. ∑ ( 2i − 1) = ( k + 1) 2 is true.
i =1
k+1 k
Proof: ∑ ( 2i − 1) = ∑ ( 2i − 1) + 2( k + 1) − 1= P( k ) + 2( k + 1) − 1
i =1 i =1
= k + 2( k + 1) − 1 = k 2 + 2k + 2 − 1 = k 2 + 2k + 1 = ( k + 1)( k + 1) = ( k + 1) 2
2
n
n 2 ( n + 1) 2
Example 18: Prove that ∑ i 3 = is true using mathematical induction.
i =1 4
1
12 (1+ 1) 2 2 2 4
Step 1: Prove for P(1). P(1) = ∑ i 3 = 13 = 1 = = = = 1. So we have
i =1 4 4 4
shown this to be true for P(1)
k
k 2 ( k + 1) 2
Step 2: Assume that P( k ) is true, i.e. that P( k ) = ∑ i 3 = is true.
i =1 4
k+1 ( k + 1) 2 ( k + 1+ 1) 2
Prove that P( k +1), i.e. ∑ i = 3
is true.
i =1 4
k+1 k
k 2 ( k + 1) 2 k 2 ( k + 1) 2 4( k + 1) 3
Proof: ∑i =∑i
i =1
3
i =1
3
+ ( k + 1) 3 =
4
+ ( k + 1) 3 =
4
+
4
k 2 ( k + 1) 2 4( k + 1)( k + 1) 2 ( k + 1) 2 [k 2 + 4( k + 1)]
= + =
4 4 4
( k + 1) 2 (k 2 + 4 k + 4) ( k + 1) 2 ( k + 2)( k + 2) ( k + 1) 2 ( k + 2) 2
= = =
4 4 4
4-9
CHAPTER 4: METHODS OF PROOFS CS218
n( n + 1)
Example 19: Prove that ∀ n ≥ 1, 1+ 2 + 3 + ... + n = is true by induction.
2
n 1
1(1+ 1) 2
Step 1: Prove for P(1). Since 1+ 2 + 3 + ... + n = ∑ i; P(1) = ∑ i = 1 = = =1
i =1 i =1 2 2
So we have shown this to be true for P(1).
k
k( k + 1)
Step 2: Assume that P( k ) is true, i.e. that P( k ) = ∑ i = is true.
i =1 2
k+1 ( k + 1)( k + 2)
Prove that P( k +1), i.e. ∑ i = is true.
i =1 2
k+1 k
k( k + 1) k( k + 1) 2( k + 1)
Proof: ∑ i = ∑ i + ( k + 1) = 2
+ k + 1=
2
+
2
i =1 i =1
k 2 + k 2k + 2 k 2 + k + 2k + 2 k 2 + 3k + 2 ( k + 1)( k + 2)
= + = = =
2 2 2 2 2
n( n + 1)
So by induction 1+ 2 + 3 + ... + n = is true.
2
Step 1: Prove for P( 5); 5 2 > 2( 5) + 1 ⇒ 25 > 10 + 1 ⇒ 25 > 11. Which is true.
Step 2: Assume that P( k ) is true, i.e. that k 2 > 2k + 1 is true. Prove that
P( k +1), i.e. ( k + 1) 2 > 2( k + 1) + 1 = 2k + 3 is true.
Step 2: Assume that P( k ) is true, i.e. that 2 k > k 2 is true. Prove that
P( k +1), i.e. 2 k+1 > ( k + 1) 2 is true.
2k 2 = k 2 + k 2 > 2k + 1 and so
4 - 10
CS218 CHAPTER 4: METHODS OF PROOFS
Step 1: Prove for P(1). P(1) = 12 (1)(1− 1) = 0, and since a person does not need a
phone line to talk to themselves, this is true.
Step 2: Assume that P( k ) is true, i.e. that 1 2 k( k − 1) lines are required for k
people is true. Prove that P( k +1), i.e. 1 2 ( k + 1)( k + 1− 1) = 1 2 ( k + 1)( k )
lines will be required for k +1 people.
Proof: If you add 1 person then k more lines will be needed, so P( k ) + k lines
k( k − 1) + 2k k 2 − k + 2k
will be needed. Thus 12 k( k − 1) + k = =
2 2
k + k k( k + 1) 1
2
= = = 2 k( k + 1)
2 2
4 - 11
CHAPTER 4: METHODS OF PROOFS CS218
4.3 SUMMARY
4.3.1 REMARKS
a
l S∞ = represents a geometric sequence summed to infinity.
1− r
l To express a decimal as a fraction:
a
3. Plug the values into the geometric sequence equation S ∞ =
1− r
l p →q≡~q →~ p
The Principle of
Mathematical Induction
The principle of Mathematical
Induction states that S n is true
for all positive integers n if :
1. S 1 is true, and
2. If S k is true, then S k+1 is true.
Note: Do not prove something 12 way then prove the other side to that point. This
is not a correct formal proof and is not acceptable.
4 - 12
CS218 CHAPTER 4: METHODS OF PROOFS
10 10 50 8
4. ∑ ( 2i + 5) + ∑ ( i + 4) 5. ∑ 4( i − 30) 6. ∑ ( 5t − 3)
i=2 i=2 i = 36 t=8
11. 10 + 13 + 16 + 19 + ...
u State the inverse, the converse, and the contrapositive of each of the following:
19. Find the first six terms of the sequence that satisfies the recurrence
relation.
21. Show that this sequence satisfies the recurrence relation a k = a k −1 + 3 for
all integers k ≥ 1
4 - 13
CHAPTER 4: METHODS OF PROOFS CS218
( − 2) 2
n
if n is even
an = ( −
2) 2 = − (n −1) for all integers n ≥ 0
n
( 2) 2 if n is odd
22. Show that this sequence satisfies the recurrence relation a k = − 2a k − 2 for
all integers k ≥ 2
a(1− r n−1 )
u Given the sequence: 1, 12 , 14 , 18 ,... and the sum of the first n terms: S n = where
1− r
a is the first term and r is the ratio of the n and n −1 terms:
2n( n + 1)( 2n + 1)
27. 2 2 + 4 2 + 6 2 + ... + ( 2n ) 2 =
3
1 1 1 n
29. + + ... + =
1× 2 2 × 3 n( n + 1) ( n + 1)
n
30. ∑2 i
= 2 n+1 − 1
i=0
32. n 3 + 2n is divisible by 3
36. 1+ 2 + 4 + ... + 2n = 2 − 2n
1 1 1 1
4 - 14
CS218 CHAPTER 4: METHODS OF PROOFS
4 - 15
CHAPTER 5: COMBINATORICS
Chapter Objectives
§ about factorials;
5-1
CHAP TER 5: COM BI NA TOR ICS CS218
u SUM RULE: If one experiment has m possible outcomes and another experiment
has n possible outcomes, then there are m + n possible outcomes when exactly one of
these experiments takes place.
l Remark 1: Sum rule: The general form of the sum rule is: If one event can
occur in n 1 ways, a second event can occur in n 2
(different) ways, a third event can occur in n 3 (still
different) ways, . . ., then there are n1 + n 2 + n 3 + ...
ways in which (exactly) one of the events can occur.
Example 1: If there are 52 ways to select a representative for the MA214 class and
49 ways to select a representative for the QT211 class, then according
to the rule of sum there are 52 + 49 ways to select a representative for
either the MA214 class or the QT211 class.
Example 2: Suppose there are seven different courses offered in the morning and
five different courses offered in the afternoon. There will be
7 + 5 choices for a student that wants to enrol in only one course.
l Remark 2: Product rule: The general form of the product rule is: If
something can happen in n1 ways, and no matter
how the first thing happens, a second thing can
happen in n 2 ways, and no matter how the first
two things happen, a third thing can happen in n 3
ways, and. . ., then all the things together can
happen in n 1 × n 2 × n 3 × ... ways.
Example 3: If there are 52 ways to select a representative for the MA214 class and
49 ways to select a representative for the QT211 class, then according
to the rule of product there will be 52 × 49 ways to select a
representative for both the MA214 class and QT211 class.
Example 4: Suppose there are seven different courses offered in the morning and
five different courses offered in the afternoon. There will be 7 × 5
choices for students who want to enrol in one course in the morning
and one in the afternoon.
5-2
MA214 CHAP TER 5: COMBINATORICS
First we consider variable names one character in length. Since such names
must consist of a single letter, there is only one event, the selection of the
letter. The event can happen in 26 ways. Hence there are 26 variable names of
length 1
Next we consider variable names two characters in length. Here there are two
events. Event 1 is the selection of the letter, event 2 is the selection of the digit.
The first event can happen in 26 ways, and the second event can happen in 10
ways, or n1 = 26 and n 2 = 10, so there must be 26 ⋅ 10, or 260, ways to construct
variable names two characters in length. Hence, there are 26 + 260, or 286,
possible variable names in D++
Example 7: 2 != 2 ⋅ 1 = 2 3 != 1⋅ 2 ⋅ 3 = 6 4 != 1⋅ 2 ⋅ 3 ⋅ 4 = 24
8! 8⋅ 7⋅ 6! 12 ⋅ 11⋅ 10 ⋅ 9 ! 12 !
Example 8: = = 8 ⋅ 7 = 56 12 ⋅ 11⋅ 10 = =
6! 6! 9! 9!
u When selecting elements from a given set, one can allow the list to contain
repetitions, or one can insist that the list not contain repetitions. One can also insist
that the order in which you select the elements matters or does not matter.
5-3
CHAP TER 5: COM BI NA TOR ICS CS218
5.3.1 k-SAMPLES
u With a k-sample order of the elements matters and elements can be repeated. The
formula for a k-sample is n k , where k is the number of samples you select from the set
of n elements.
Example 9: A computer represents integers with n-binary digits, using one bit
(binary digit) to indicate the sign and the remaining n −1 bits to
represent the magnitude of the integer. This is called sign-
magnitude representation of integers. How many distinct integers
can be represented in this notation?
There are n slots to fill, and each slot can be filled in two different ways.
Hence, there are 2 n distinct patterns. However, 0 is represented as + 0 and as
−
0, so there are 2 n − 1 distinct integers that can be represented using n bits in
the sign-magnitude representation.
Example 10: A number consists of 5 digits such that the sum of the first and last
digits must be even. Repetition of digits is allowed; however, the
number cannot consist of all zeros. How many different numbers
are there?
There are two ways for the sum of the first and last digits to be even: when you
add two odd numbers together, and when you add two even numbers together.
Note that there are 5 digits that are odd, 1, 3, 5, 7, and 9, and 5 that are even,
0, 2, 4, 6, and 8.
Case 1: First and last digits odd, gives us 5 ⋅ 10 ⋅ 10 ⋅ 10 ⋅ 5, which is 25000
numbers.
Case 2: First and last digits even, gives us 5 ⋅ 10 ⋅ 10 ⋅ 10 ⋅ 5 = 25000 choices
also; however, 1 choice is all 0’s which is not allowed giving us a
final answer of 25000 + 25000 − 1 = 49999 numbers.
5.3.2 k-PERMUTATIONS
u With a k-permutation the order of the elements matters, but repetition of the
elements is not allowed. The formula for a k-permutation is P( n , k ) =
n!
, where
( n − k)!
k≤n
Example 11: Find the number of “words” with four distinct letters that can be
made from the letters c, a , b , i, n , e, t.
Here n = 7, and k = 4.
7! 7⋅ 6⋅ 5⋅ 4 ⋅ 3⋅ 2⋅ 1
P( 7, 4 ) = = = 7 ⋅ 6 ⋅ 5 ⋅ 4 = 840
3! 3⋅ 2⋅ 1
5-4
CS218 CHAP TER 5: COMBINATORICS
Example 12: A number consists of 5 digits such that the sum of the first and
last digits must be even. Repetition of digits is not allowed. How
many different numbers are there?
This problem is similar to that of example 10; however in this case repetition of
the digits is not allowed, which means that we have 5 ⋅ 8 ⋅ 7 ⋅ 6 ⋅ 4 possible
numbers. Since there are again two cases which are exactly the same, we have
2 ⋅ 5 ⋅ 8 ⋅ 7 ⋅ 6 ⋅ 4 = 13440 numbers. This can also be expressed as 2 ⋅ P( 5 , 2) ⋅ P( 8, 3)
5! 8!
= 2⋅ ⋅ = 13440 numbers.
3! 5!
5.3.3 k-COMBINATIONS
u With a k-combination the order in which the elements are selected does not matter
and the elements cannot repeat. The formula for a k-combination is
C( n , k ) =
n!
( n − k ) !k !
n
l Remark 5: k-combinations can be written as n C k , n C k , , or as C( n , k )
k
Example 13: A menu in a Chinese restaurant allows you to order exactly two of
eight main dishes as part of the dinner special. How many different
combinations of main dishes could you order?
There are 8 C 2 combinations of the eight main dishes taken two at a time.
8! 8⋅ 7
Thus, you could choose one of 8 C 2 = = = 28 different combinations.
6! 2! 2
Example 14: A group consists of seven men and five women. Find the number m
of committees of five that can be selected from the group.
Example 15: Suppose in forming a committee from seven men and five women,
that the committee m of 5 members is to consist of three men and
two women. How many committees can be formed?
In this case the three men can be chosen from the seven men in 7 C 3 ways, and
the two women can be chosen from the five women in 5 C 2 ways. Hence
7 5 7! 5! 7⋅ 6⋅ 5⋅ 5⋅ 4
m= = = = 350 committees.
3 2 3 ! 4 ! 2 ! 3 ! 3⋅ 2⋅ 2
Example 16: Suppose in forming a committee from seven men and five women,
that the committee m, of 5 members, must consist of at least one
man and at least one woman. How many committees can be
formed?
Using the result from example 14, there are 12 C 5 = 792 possible committees.
Among these committees, there is 5 C 5 = 1 committee consisting of the five
women, and 7 C 5 = 21 consisting of five men. These committees are not allowed
so eliminating them from the possible committees yields m = 792 − 21− 1 = 770
committees.
5-5
CHAP TER 5: COM BI NA TOR ICS CS218
5.3.4 k-SELECTIONS
u k-selections is similar to k-combinations in that the order in which you select the
elements does not matter, but in this case repetitions can occur. The formula for a
k-selection is n+k −1C k ∀ n , k ≥ 1
4+3−1
6! 6⋅ 5⋅ 4
C 3 = 6C 3 = = = 20
3! 3! 3⋅ 2
Example 18: Four dice are to be tossed. How many different outcomes are
possible if the order does not matter?
If the first die shows 4 and the rest of the dice show 2, it is the same outcome
as if the first three dice show 2 and the last one shows 4. Hence, order does not
matter. But since all dice could show the same value, repetitions are allowed.
Thus the outcomes are the 4-selections from the set {1, 2, 3, 4 , 5, 6}, and there are
6+4 −1 9! 9⋅ 8⋅ 7⋅ 6
C4 = 9
C4 = = = 126 possible outcomes.
4 ! 5! 4 ⋅ 3⋅ 2
Example 19: How many ways are there to choose 8 coins from a pile containing
100 identical pennies and 80 identical nickels?
Since the coins are identical the order in which the coins are selected does not
matter. Further since all pennies and all nickels have the same value repetition
is allowed. So we have 8-selections not from 100 + 80 = 180 coins, but from the
two different types of coins, i.e. a penny and a nickel. So we have 2+8 −1C 8 = 9 C 8
9!
= = 9 ways.
1! 8 !
Example 20: A hockey team has ten players who want to play in the front line.
How many 3-player lines can be formed if a player can be in more
than one line?
Here the order in which the players are selected does not matter, and
repetition of the players can also occur, since it is possible for a player to be in
more than one line. So we have 3-selections of players from 10, which is 10+3−1C 3
12 ! 12 ⋅ 11⋅ 10
= 12C 3 = = = 220 ways.
9! 3! 3⋅ 2
u Many results in combinatorial theory come from the following almost obvious
statement:
5-6
CS218 CHAP TER 5: COMBINATORICS
Example 22: Suppose a laundrybag contains many red, white, and blue socks.
Find the minimum number of socks that one needs to choose in
order to get two pairs (four socks) of the same colour.
| A ∪ B ∪ C | = | A | + | B | + |C | − | A ∩ B | − | A ∩ C | − | B ∩ C | − | A ∩ B ∩ C |
| M ∪ E ∪ J | = | M | + | E| + | J | − | M ∩ E| − | M ∩ J | − | E ∩ J | +
| M ∩ E ∩ J | = 65 + 45 + 42 − 20 − 25 − 15 + 8 = 100
5.6 PARTITIONS
5-7
CHAP TER 5: COM BI NA TOR ICS CS218
Example 24: Find the number m of ways that nine toys can be divided between
four children if the youngest child is to receive three toys and each
of the others two toys.
We wish to find the number m of ordered partitions of the nine toys into four
cells containing 3, 2, 2, 2 toys respectively. By Theorem 4,
9!
m= = 7560
3! 2! 2! 2!
Example 25: A puzzle has three squares, two triangles, and four circles. How
many patterns can be formed by laying these nine shapes out in a
row?
9! 9⋅ 8⋅ 7⋅ 6⋅ 5
= = 1260 ways.
3! 2! 4 ! 3⋅ 2⋅ 2
n!
P ( n; n 1 , n 2 ,K , n r ) = where P ( n; n 1 , n 2 ,K , n r ) denotes the
n 1 ! n 2 ! n 3 !L n r !
number of permutations of n objects of which n1 are alike, n 2 are alike, . . ., n r
are alike.
Example 26: Find the number of all possible five-letter “words” using the letters
from the word “apple”.
What we have is five letters in which two of them repeat, so this is a type of
5!
problem involving a permutation with repetition, or = 5 ⋅ 4 ⋅ 3 = 60 ways.
2!
Example 27: How many different signals, each consisting of six flags hung in a
vertical line, can be formed from four identical red flags and two
identical blue flags?
u In each example from section 5.6.1 the order in which we placed the items made a
difference, i.e. order mattered. There are times when you will want to partition a set
A into a collection of subsets A1 , A 2 ,K , A r where the subsets are now unordered;
where the order in which the sets are placed does not make a difference.
u This type of problem can be solved in two ways, as you will see in the next example.
5-8
CS218 CHAP TER 5: COMBINATORICS
Example 28: Find the number m of ways that 12 students can be partitioned into
three teams, A1 , A 2 , and A 3 , so that each team contains four
students.
11
Method 1: Let A denote one of the students. Then there are ways to
3
choose three other students to be on the same team as A. Now let
B denote a student who is not on the same team as A; then there
7
are ways to choose three students of the remaining students to
3
be on the same team as B. The remaining four students constitute
the third team. Thus, altogether, the number of ways to partition
the students is
11 7
m = ⋅ = 165 ⋅ 35 = 5775
3 3
u We also need a way to count the number of partitions that can be formed from a given
set, however, there is no simple closed form expression for this, but there is a simple
recurrence relation that express it.
Exercise 29: In how many ways can a set with five elements be partitioned into
three blocks?
S ( 4 , 3) = 3S ( 3, 3 ) + S ( 3, 2) S ( 4 , 2) = 2S ( 3, 2) + S ( 3, 1)
S ( 3, 2) = 2S ( 2, 2 ) + S ( 2, 1) S ( 2, 1) = S ( 3, 1) = 1
S ( 3, 3) = 1 S ( 2, 2) = 1
S ( 3, 2) = 2 + 1 = 3 S ( 4 , 2) = 2 ⋅ 3 + 1 = 7 S ( 4 , 3) = 3 + 3 = 6
Finally, S ( 5, 3) = 3 ⋅ 6 + 7 = 25
5-9
CHAP TER 5: COM BI NA TOR ICS CS218
5.7 SUMMARY
5.7.1 FORMULAS
u Factorial: n != n ⋅ ( n − 1) ⋅ ( n − 2) ⋅K⋅ 2 ⋅ 1
n!
u Permutations: P(n , r) = ( = n( n − 1)( n − 2)K( n − r + 1), where n is the number of
n − r) !
objects and r is the number selected.
n!
u Permutations with Repetitions: where you have n objects of which n1
n 1 ! n 2 !K n r !
are alike, n 2 are alike, . . ., n r are alike.
P( n , r) n! n
u Combinations: n C r = = = , where n is the number of objects taken
r! r !( n − r) ! r
r at a time.
u Combinations with repetitions: n+r −1C r , where n is the number of elements and r
is number of selections.
u Number of Partitions: The number of ways to partition a set with n elements into
k blocks is given by S ( n , k ), where S ( n , k ) satisfies the following recurrence relation:
5.7.2 THEOREMS
| A ∪ B ∪ C | = | A | + | B | + |C | − | A ∩ B | − | A ∩ C | − | B ∩ C | − | A ∩ B ∩ C |
l Suppose there are n objects, of which n 1 objects are of type 1, n 2 objects are of type
n!
2, and so on, up to n r objects of type r. Then there are distinct
( n1 !)( n2 !)K( nr !)
patterns that can be formed with the n objects. Moreover, each pattern appears
exactly ( n 1 !)( n 2 !)K( n r !) times among the n ! permutations.
l The number of ways to partition a set with n elements into k blocks is given by
S ( n , k ), where S ( n , k ) satisfies the following recurrence relation:
5-10
CS218 CHAP TER 5: COMBINATORICS
5.7.3 REMARKS
l Sum rule: If one event can occur in n1 ways, a second event can occur in n 2
(different) ways, a third event can occur in n 3 (still different)
ways, . . ., then there are n 1 + n 2 + n 3 + ... ways in which (exactly)
one of the events can occur.
l Product rule: If something can happen in n 1 ways, and no matter how the
first thing happens, a second thing can happen in n 2 ways,
and no matter how the first two things happen, a third thing
can happen in n 3 ways, and. . ., then all the things together
can happen in n1 × n 2 × n 3 × ... ways.
l 0 != 1 1!= 1 and n ! = n ⋅ ( n −1) !
l k-permutations can be written as n Pk , n Pk , or as P( n , k )
n
l k-combinations can be written as n C k , n C k , or as C( n , k )
k
5.7.4 TABLE
C ( n, k ) =
n!
Elements not repeated P( n , k ) = (
n!
n − k )! ( n − k ) !k !
5-11
CHAP TER 5: COMBINATORICS CS218
u Compute.
7
1. P( 20, 17) 2. C(13, 9) 3. 4. 7
P5 5. 7+5−1
C5 6. S ( 6, 4 )
5
u Let S = {1, 2, 3, 4}, using the correct formula find the number of:
7. 2-samples
8. 2-selections
9. 2-permutations
10. 2-combinations
u Permutations
11. There are four bus lines between A and B; and three bus lines between B
and C. In how many ways can a man travel
13. Find the number of ways that a party of seven persons can arrange
themselves:
(a) in a row of seven chairs
(b) around a circular table
14. Find the number of distinct permutations that can be formed from the
letters of the following words:
(a) RADAR
(b) UNUSUAL
(c) MISSISSIPPI
(d) COMPILER
(e) DISCRETE
15. In how many ways can four mathematics books, three history books,
three chemistry books, and two sociology books be arranged on a shelf so
that all books of the same subject are together?
5-12
CS218 CHAP TER 5: COMBINATORICS
u Combinations
17. In how many ways can a committee consisting of three men and two
women be chosen from seven men and five women?
18. A bag contains six white marbles and five red marbles. Find the number
of ways four marbles can be drawn from the bag if
(a) they can be any colour
(b) two must be white and two red
(c) they must all be of the same colour
19. How many committees of five with a given chairperson can be selected
from 12 persons?
20. In how many ways can nine students be partitioned into three teams
containing four, three, and two students, respectively?
21. There are 12 students in a class. In how many ways can the 12 students
take four different tests if three students are to take each test?
22. In how many ways can 12 students be partitioned into four teams,
A1 , A 2 , A 3 , and A 4 , so that each team contains three students.
23. Assume there are n distinct pairs of shoes in a closet. Show that if you
choose n +1 single shoes at random from the closet, you are certain to have
a pair.
24. Assume there are three men and five women at a party. Show that if
these people are lined up in a row, at least two women will be next to each
other.
25. Find the minimum number of students needed to guarantee that five of
them belong to the same class (sec1, sec2, sec3, sec4).
5-13
CHAP TER 5: COMBINATORICS CS218
27. Find the minimum number n of integers to be selected from S = {1, 2,K , 9}
so that:
(a) the sum of two of the n integers is even
(b) the difference of two of the n integers is 5
28. There are 22 female students and 18 male students in a classroom. How
many students are there in total?
29. Of 32 people who save paper or bottles (or both) for recycling, 30 save
paper and 14 save bottles. Find the number m of people who
(a) save both
(b) save only paper
(c) save only bottles
u Miscellaneous Problems
31. A student must take five classes from three areas of study. Numerous
classes are offered in each discipline, but the student cannot take more
than two classes in any given area.
(a) Using the pigeonhole principle, show that the student will take at
least two classes in one area.
(b) Using the inclusion-exclusion principle, show that the student will
have to take at least one class in each area.
32. How many different 7-card hands can be drawn from a standard 52-card
deck?
33. How many different 3-note sequences can be formed from an 8-note
scale?
34. A hockey team has ten players who want to play in the front line. How
many distinct 3-player lines can be formed?
35. A certain software package has three main modules. To configure the
package, users must choose among options given for each module. If the
first module has four options, the second five options, and the third
three options, how many different sets of options are supported?
37. Are there more 4-samples or more 4-selections from a set with six
elements?
5-14
CS218 CHAP TER 5: COMBINATORICS
38. A salesperson is to visit eight different cities exactly once. In how many
different ways can this be done?
39. Three exams are to be scheduled during a four-day period, with at most
one exam per day. In how many ways can this be accomplished?
40. Find the number of patterns that can be formed by permuting the
letters of the word reentrant?
41. How many ways can a set with three elements be partitioned?
43. A committee of three has to elected from a group of 9 people. This group
consists of 5 men and 4 women. How many different committees can be
can be formed?
46. A box contains eight black balls and six white balls. In how many ways
can four balls be chosen so that:
(a) exactly two black balls are chosen.
(b) at least three black balls are chosen.
(c) at least one white ball is chosen.
47. A box contains nine red balls and eight blue balls and seven white balls.
In how many ways can you draw three balls given:
(a) that the three balls are all the same colour.
(b) that you replace the balls after drawing them and all the balls are
the same colour?
(c) that all three balls are a different colour?
(d) that you replace the balls after drawing them and that all the balls
are a different colour?
49. A sample of 80 car owners revealed that 24 owned station wagons and 62
owned cars which are not station wagons. Find the number k of people
who owned both a station wagon and some other car.
5-15
CHAP TER 5: COMBINATORICS CS218
51. Suppose 12 people read the Wall Street Journal (W) or Business Week (B)
or both. Given three people read only the Journal and six read both, find
the number k of people who read only Business Week .
52. Show that any set of seven distinct integers insludes two integers, x and y,
such that either x + y or x − y is divisible by 10.
54. Suppose that there are 8 runners in a race. The awards given are gold for
the winner, silver for the person who comes second, and bronze for the
person who comes third. How many different ways are there to award
these medals if all possible outcomes of the race can occur?
56. How many 6-digit postal codes are there if the first two digits and the last
three digits cannot be 0?
57. A box contains eight black balls and six white balls. In how many ways
can four balls be chosen so that:
a) exactly two black balls are chosen?
b) at least three black balls are chosen?
c) at most one white ball is chosen?
58. A multiple choice test contains 10 questions; there are 4 possible answers
for each question.
a) How many ways can a student answer the questions on the test if
every question is answered?
b) How many ways can a student answer the questions on the test if
the students can leave answers blank?
5-16
CS218 CHAP TER 5: COMBINATORICS
60. How many bit strings contain exactly eight 0’s and ten 1’s if every 0 must
be followed immediately by a 1?
61. Suppose that a department contains 10 men and 15 women. How many
ways are there to form a committee with 6 members if it must have the
same number of men and women?
5-17
CHAPTER 6: PROBABILITY
Chapter Objectives
§ how to find the probability of an event given another event has occurred;
6-1
CHAPTER 6: PROBABILITY CS218
u The set S of all possible outcomes of some given experiment is called the sample
space.
u An event A is a set of outcomes or, in other words, a subset of the sample space S.
u The empty set ∅ and S itself are events; ∅ is called the impossible event, and S the
certain or sure event.
u Since an event is a set, we can combine events to form new events using the various
set operations:
(iii) A c , the complement of A is the event that occurs if A does not occur.
u Two events A and B are called mutually exclusive if they are disjoint, i.e. if
A ∩ B = ∅. In other words, A and B are mutually exclusive if they cannot occur
simultaneously.
Example 1: Toss a die and observe the number that appears on top.
The sample space S consists of the six possible numbers; that is, S = {1, 2, 3, 4 , 5, 6}
Let A be the event that an even number occurs, B that an odd number occurs,
and C that a prime number occurs; that is, let
6-2
CS218 CHAPTER 6: PROBABILITY
l Theorem 1: Let S be a sample space, let E be the class of events, and let P
be a real-valued function defined on E. Then P is called a
probability function, and P( A ) is called the probability
of the event A if the following axioms hold:
[P1 ] For every event A , 0 ≤ P( A ) ≤ 1
[P2 ] P( S ) = 1
l Theorem 4: If A ⊆ B, then P( A ) ≤ P ( B )
By definition P ( B ∪ C ) = P ( B ) + P (C ) − P ( B ∩ C ) = 27 + 17 − 0 = 37
6-3
CHAPTER 6: PROBABILITY CS218
number of elements in A
P( A ) =
number of elements in S
or
number of ways that the event A can occur
P( A ) =
number of ways that the sample space S can occur
u It must be emphasized that the above formula for P( A ) can only be used with respect
to an equiprobable space, i.e. that each sample point in S must have the same
probability.
u The expression “ at random” will be used only with respect to an equiprobable space;
formally the statement “choose a point at random from a set S” shall mean that S is
an equiprobable space, i.e. that each sample point in S has the same probability.
number of spades 13 1
P( A ) = = =
number of cards 52 4
S can occur in 12
C 2 = 66 ways, the number of ways that 2 items can be chosen
from 12 items;
A can occur in 4
C 2 = 6 ways, the number of ways that 2 defective items can
be chosen from 4 defective items;
B can occur in 8
C 2 = 28 ways, the number of ways that 2 non-defective items
can be chosen from 8 non-defective items.
6 1 28 14
Accordingly, P( A ) = = and P( B ) = =
66 11 66 33
6-4
CS218 CHAPTER 6: PROBABILITY
Example 6: What is the probability that at least one item is defective from
example 5?
Example 7: What are the odds that at least one item is defective from example 5?
19 14
The odds that at least one item is defective are ⋅ or 19 :14 which
33 33
is read “19 to 14”
u Let E be an arbitrary event in a sample space S with P( E ) > 0. The probability that an
event A occurs once E has occurred or, in other words, the conditional probability
of A given E, written P( A | E ), is defined as follows:
P( A ∩ E )
P( A | E ) =
P( E )
or P( A | E ) =
number of ways A and E can occur
number of ways E can occur
Example 8: Let a pair of fair dice be tossed. If the sum is 6, find the probability
that one of the dice is 2. In other words, if
E = {sum is 6} = {(1, 5), ( 2, 4 ), ( 3, 3), ( 4 , 2), ( 5, 1)} and
A = {a 2 appears on at least one die} find P( A | E ) and P ( A )
Now E consists of five elements and two of them, ( 2, 4 ) and ( 4 , 2), belong
to A: A ∩ E = {( 2, 4 ), ( 4 , 2)} =
2 5
and P ( E ) =
36 36
2
P( A ∩ E )
Then P( A | E ) =
36 2
= =5
P (E ) 5
36
6-5
CHAPTER 6: PROBABILITY CS218
Example 9: A man visits a couple who have two children. One of the children, a
boy, comes into the room. Find the probability p that the other child
is also a boy if (i) the other child is known to be younger, (ii) nothing
is known about the other child.
The sample space for the sex of two children is S = {bb , bg , gb , gg} with
probability 14 for each point. (Here the sequence of each point corresponds to
the sequence of births).
(i) The reduced sample space consists of two elements, {bb , bg}; hence p = 12
(ii) The reduced sample space consists of three elements, {bb , bg , gb}; hence
p= 3
1
Example 10: A lot contains 12 items of which 4 are defective. Three items are
drawn at random from the lot one after the other. Find the
probability p that all three are not defective.
The probability that the first item is not defective is 128 since 8 of 12 items are
not defective. If the first item is not defective, then the probability that the
next item is not defective is 11 since only 7 of the remaining 11 items are not
7
defective. If the first two items are not defective, then the probability that the
last item is not defective is 10 since only 6 of the remaining 10 items are now
6
6.3.2 STO CHAS TIC PROC ESSES & TREE DIA GRAMS
6-6
CS218 CHAPTER 6: PROBABILITY
The following tree diagram describes this process and gives the probability of
each branch of the tree:
The probability that any particular path of the tree occurs is, by the
multiplication theorem, the product of the probabilities of each branch of the
path, i.e., the probability of selecting box I and then a defective bulb is 13 ⋅ 25 = 152
Now since there are three mutually exclusive paths which lead to a defective
bulb, the sum of the probabilities of these paths is the required probability:
p = 13 ⋅ 25 + 13 ⋅ 61 + 13 ⋅ 83 = 113
360
Example 12: A coin, weighted so that P( H ) = 23 and P(T ) = 13, is tossed. If heads
appears, then a number is selected at random from the numbers 1
through 9; if tails appears, then a number is selected at random
from the numbers 1 through 5. Find the probability p that an even
number is selected.
The tree diagram with respective probabilities is
Note that the probability of selecting an even number from the numbers 1
through 9 is 49 since there are 4 even numbers out of the 9 numbers, whereas
the probability of selecting an even number from the numbers 1 through 5 is 5
2
since there are 2 even numbers out of the 5 numbers. Two of the paths lead to
an even number: HE and TE. Thus p = P( E ) = 23 ⋅ 49 + 13 ⋅ 25 = 135
58
6.4 INDEPENDENCE
6-7
CHAPTER 6: PROBABILITY CS218
Example 13: Let a fair coin be tossed three times; we obtain the equiprobable
space S = { HHH, HHT, HTH, HTT, THH, THT, TTH, TTT}. Consider the
events A = {first toss is heads}, B = {second toss is heads},
C = {exactly two heads are tossed in a row}. Show that A and B and A
and C are independent events, and that B and C are dependent
events.
P( A ∩ C ) = P({HHT}) = 8
1
P( B ∩ C ) = P({HHT, THH}) = 4
1
u Frequently, we will postulate that two events are independent, or it will be clear from
the nature of the experiment that two events are independent.
Example 14: The probability that A hits a target is 14 and the probability that B
hits it is 25. What is the probability that the target will be hit if A and
B each shoot at the target?
P( A ∪ B ) = P( A ) + P( B ) − P( A ∩ B ) = P( A ) + P( B ) − P( A )P( B ) = 41 + 25 − 14 ⋅ 25 = 11
20
u Condition (ii) does not follow from condition (i); in other words, three events may be
pairwise independent but not independent themselves, as is shown in the next
example.
Example 15: Let a pair of fair coins be tossed; here S = {HH, HT, TH, TT} is an
equiprobable space. Consider the events
6-8
CS218 CHAPTER 6: PROBABILITY
Example 16: Whenever three horses a, b, and c race together, their respective
probabilities of winning are 2 , 3 and 6 . In other words, S = {a , b , c}
1 1 1
The sample space is T = {aa , ab , ac, ba , bb , bc, ca , cb , cc} for the 2 repeated
trials, where to simplify things we write ac for the ordered pair ( a , c).
The probability of ac is P ( ac) = P( a )P( c) = 2 ⋅ 6 = 12
1 1 1
u Let X be a random variable on a sample space S with a finite image set; say
X ( S ) = {x1 , x 2 ,K , xn}. We make X ( S ) into a probability space by defining the
probability of xi to be P( X = x i ) which we write as f ( x i ). This function f on X ( S ), i.e.
defined by f ( xi ) = P ( X = xi ), is called the distribution or probability function of
X and is usually given in the form of a table:
x1 x2 L xn
f ( x1 ) f (x 2 ) L f ( xn )
6-9
CHAPTER 6: PROBABILITY CS218
u Now if X is a random variable with the above distribution, then the mean or
expectation or expected value of X, denoted by E( X ) or µ, is defined by
n
E( X ) = x1 f ( x1 ) + x2 f ( x 2 ) +K+ xn f ( xn ) = ∑ xi f ( xi )
i =1
That is, E( X ) is the weighted average of the possible values of X, each value
weighted by its probability.
Example 17: A pair of fair dice is tossed. We obtain the finite equiproable space S
consisting of the 36 ordered pairs of numbers between 1 and 6:
X ( S ) = {1, 2, 3, 4 , 5, 6}
Similarly,
f ( 5) = P( X = 5) = 369 and f ( 6) = P( X = 6) = 11
36
xi 1 2 3 4 5 6
f (x i )
1 3 5 7 9 11
36 36 36 36 36 36
Example 18: Let Y assign to each point ( a , b ) in S = {(1, 1), (1, 2),K , ( 6, 6)} the sum
of its numbers, i.e. Y ( a , b ) = a + b. Then Y is also a random variable
on S with the image set Y ( S ) = {2, 3, 4 , 5, 6, 7, 8, 9, 10, 11, 12}. Compute
the distribution g and mean of Y
yi 2 3 4 5 6 7 8 9 10 11 12
g ( yi )
1 2 3 4 5 6 5 4 3 2 1
36 36 36 36 36 36 36 36 36 36 36
i =1
6 - 10
CS218 CHAPTER 6: PROBABILITY
Example 19: A coin weighted so that P( H ) = 3 and P(T ) = 3 is tossed three times.
2 1
P( HTT) = 3 ⋅ 3 ⋅ 3 = 27 P( TTT) = 3 ⋅ 3 ⋅ 3 = 27
2 1 1 2 1 1 1 1
f ( 0) = P( TTT ) = 27
1
f ( 3) = P( HHH) = 278
xi 0 1 2 3
f ( xi )
1 10 8 8
27 27 27 27
E( X ) = ∑ xi f ( xi ) = 0 ⋅ 271 + 1⋅ 10
27 + 2 ⋅ 27 + 3 ⋅ 27 = 27 = 185
8 8 50
.
12
The sample space S consists of the = 220 distinct equally likely samples of
3
size 3. Note that there are:
9
= 84 samples with no defective items;
3
9
3 ⋅ = 108 samples with 1 defective item;
2
6 - 11
CHAPTER 6: PROBABILITY CS218
3
9 ⋅ = 27 samples with 2 defective items;
2
3
=1 sample with 3 defective items;
3
E = 0 ⋅ 220
84
+ 1⋅ 108
220 + 2 ⋅ 220 + 3 ⋅ 220 = 220 = 0.75
27 1 165
u The mean of a random variable X measures, in a certain sense, the “average” value of
X. The variance of X measures the “spread” or “dispersion” of X
x1 x2 L xn
f ( x1 ) f ( x 2 ) L f (x n )
(( X − µ) )
n
Var(X) = ∑ ( xi − µ ) f ( x i ) = E
2 2
i =1
σ X = Var( X )
u The following theorem gives an alternate and sometimes more useful formula for
calculating the variance of the random variable X.
n
l Theorem 9: Var(X) = ∑ xi2 f ( xi ) − µ 2 = E( X 2 )− µ 2
i =1
Example 22: Consider the random variable X from example 17 (which assigned
the maximum of the numbers showing on a pair of dice). Compute
the variance and standard deviation of X.
xi 1 2 3 4 5 6
f ( x i ) 36
1 3 5 7 9 11
36 36 36 36 36
6 - 12
CS218 CHAPTER 6: PROBABILITY
Example 23: Compute the variance and standard deviation of Y the random
variable of example 18 (which assigned the sum of the numbers
showing on a pair of dice).
yi 2 3 4 5 6 7 8 9 10 11 12
g ( yi ) 36
1 2 3 4 5 6 5 4 3 2 1
36 36 36 36 36 36 36 36 36 36
u If we are interested in the number of successes and not in the order in which they
occur, then the following theorem applies.
Example 24: A fair coin is tossed 6 times or, equivalently, six fair coins are
tossed; call heads a success. Then n = 6 and p = q = 2
1
= 64 + 64 + 64 = 32
15 6 1 11
Example 25: A fair die is tossed 7 times; call a toss a success if a 5 or a 6 appears.
Then n = 7, p = P({5, 6}) = 13 and q = 1− p = 23
6 - 13
CHAPTER 6: PROBABILITY CS218
k 0 1 2 L n
P( k ) qn ( 1n )q n−1 p ( n2 )q n− 2 p 2 L pn
( q + p) n = q n + ( 1n )q n−1 p + ( n2 )q n− 2 p 2 +L+ p n
Binomial Distribution
Mean µ = np
Variance σ 2 = npq
Standard deviation σ = npq
Example 26: A fair die is tossed 180 times. Find the expected number of sixes,
and the standard deviation.
6 - 14
CS218 CHAPTER 6: PROBABILITY
6.8 SUMMARY
6.8.1 THEOREMS
l Let S be a sample space, let E be the class of events, and let P be a real-valued
function defined on E. Then P is called a probability function, and P( A ) is
called the probability of the event A if the following axioms hold:
[P1 ] For every event A , 0 ≤ P( A ) ≤ 1
[P2 ] P( S ) = 1
[P3 ] If A and B are mutually exclusive events, then P( A ∪ B ) = P( A ) + P( B )
[P4 ]If A1 , A 2 ,K is a sequence of mutually exclusive events, then
P ( A1 ∪ A 2 ∪ K ) = P ( A1 ) + P ( A 2 ) + K
l If ∅ is the empty set, then P( ∅) = 0
l If A c is the complement of an event A, then P( A c ) = 1− P( A )
l If A ⊆ B, then P( A ) ≤ P( B )
l Multiplication Theorem: P( E ∩ A ) = P( E )P ( A | E )
6.8.2 REMARKS
6 - 15
CHAPTER 6: PROBABILITY CS218
(ii) either A or B, but not both, occurs, i.e. exactly one of the two events
occurs.
2. Let A, B and C be events. Find an expression and exhibit the Venn diagram
for the event that
3. Let a coin and a die be tossed; let the sample space S consist of the twelve
elements: S = {H1, H2, H3, H4, H5, H6, T1, T2, T3, T4, T5, T6}
(ii) Express explicitly the event that: (a) A or B occurs, (b) B and C
occurs, (c) only B occurs
(i) P( a1 ) = 2 , P( a 2 ) = 3 , P( a 3 ) = 4 , P( a 4 ) = 5
1 1 1 1
(ii) P( a1 ) = 2 , P( a 2 ) = 4 , P( a 3 ) = − 4 , P( a 4 ) = 2
1 1 1 1
(iii) P( a1 ) = 2 , P( a 2 ) = 4 , P( a 3 ) = 8 , P( a 4 ) = 8
1 1 1 1
(iv) P( a1 ) = 2 , P( a 2 ) = 4 , P( a 3 ) = 4 , P( a 4 ) = 0
1 1 1
(i) Find P( a 1 ) if P( a 2 ) = 3 , P( a 3 ) = 6 , P( a 4 ) = 9
1 1 1
6 - 16
CS218 CHAPTER 6: PROBABILITY
(ii) If m1 and w1 are married, find the probability that one of them wins
the tournament
(i) Describe the probability space, i.e. find the probability of each
sample point
(iii) at least one tail appears in the toss of three fair coins
10. Two cards are drawn at random from an ordinary pack of 52 cards. Find
the probability p that
11. Three light bulbs are chosen at random from 15 bulbs of which 5 are
defective. Find the probability p that
12. Two cards are selected at random from 10 cards numbered 1 to 10. Find
the probability p that the sum is odd if
6 - 17
CHAPTER 6: PROBABILITY CS218
(ii) the two cards are drawn one after the other without replacement
(iii) the two cards are drawn one after the other with replacement
(iii) If the 12 people are divided into six pairs, find the probability p that
14. A class contains 10 men and 20 women of which half the men and half the
women have brown eyes. Find the probability p that a person chosen at
random is a man or has brown eyes.
u Conditional probability
15. A pair of dice is thrown. Find the probability p that the sum is 10 or
greater if
16. Three fair coins are tossed. Find the probability p that they are all heads
if
17. A pair of fair dice is thrown. If the two numbers appearing are different,
find the probability p that
18. Two digits are selected at random from the digits 1 through 9. If the sum
is even, find the probability p that both numbers are odd.
6 - 18
CS218 CHAPTER 6: PROBABILITY
20. Four people, called North, South, East and West, are each dealt 13 cards
from an ordinary pack of 52 cards.
(i) If South has no aces, find the probability p that his partner North
has exactly two aces.
(ii) If North and South together have nine hearts, find the probability p
that East and West each has two hearts.
u Multiplication theorem
21. A class has 12 boys and 4 girls. If three students are selected at random
from the class, what is the probability p that they are all boys?
22. A man is dealt 5 cards one after the other from an ordinary pack of 52
cards. What is the probability p that they are all spades?
23. An urn contains 7 red marbles and 3 white marbles. Three are drawn
from the urn one after the other. Find the probability p that the first two
are red and the third is white.
24. The students in a class are selected at random, one after the other, for an
examination. Find the probability p that the boys and girls in the class
alternate if
25. A box contains three coins; one coin is fair, one coin is two-headed, and
one coin is weighted so that the probability of heads appearing is 13. A coin
is selected at random and tossed. Find the probability p that heads
appears.
26. Box A contains nine cards numbered 1 through 9, and box B contains five
cards numbered 1 through 5. A box is chosen at random and a card
drawn. If the number is even, find the probability that the card came
from box A.
An urn is selected at random and a marble is drawn from teh urn. If the
marble is red, what is the probability that it came from urn A?
6 - 19
CHAPTER 6: PROBABILITY CS218
28. An urn contains 3 red marbles and 7 white marbles. A marble is drawn
from the urn and a marble of the toher colour is then put into the urn. A
second marble is drawn from the urn.
(ii) If both marbles were of the same colour, what is the probability p
that they were both white?
An urn is selected at random; a marble is drawn and put into the other
urn; then a marble is drawn from the second urn. Find the probability
p that both marbles drawn are of the same colour.
u Independence
30. Let A = event that a family has children of both sexes, and let B = event
that a family has at most one boy.
(i) Show that A and B are independent events if a family has three
children.
(ii) Show that A and B are dependent events if a family has two
children.
31. The probability that a man will live 10 more years is 41, and the probability
that his wife will live 10 more years is 3. Find the probability that
1
32. Box A contains 8 items of which 3 are defective, and box B contains 5
items of which 2 are defective. An item is drawn at random from each
box.
(ii) What is the probability p that one item is defective and one not?
(iii) If one item is defective and one is not, what is the probability p that
the defective item came from box A?
33. The probabilities that three men hit a target are respectively 61 , 1
4 and 13.
Each shoots once at the target.
(i) Find the probability p that exactly one of them hits the target.
(ii) If only one hit the target, what is the probability that it was the
first man?
6 - 20
CS218 CHAPTER 6: PROBABILITY
u Repeated trials
34. A certain type of missile hits its target with probability 0.3. How many
missiles should be fired so that there is at least an 80% probability of
hitting a target?
35. A certain soccer team wins (W) with the probability 0.6, loses (L) with the
probability 0.3 and ties (T) with the probability 0.1. The team plays three
games over the weekend.
(i) Determine the elements of the event A that the team wins at least
twice and doesn’t lose; and find P(A).
(ii) Determine the elements of the event B that the team wins, loses
and ties; and find P(B).
(i)
xi 2 3 11
f ( xi )
1 1 1
3 2 6
(ii)
− −
xi 5 4 1 2
f ( xi ) 1
4
1
3
1
2
1
8
(iii)
xi 1 3 4 5
f ( xi ) 0.4 0.1 0.2 0.3
37. A fair die is tossed. Let X denote twice the number appearing, and let Y
denote 1 or 3 according to whether an odd or an even number appears.
Find the distribution, expectation, expectation, variance and standard
deviation of
(i) X
(ii) Y
(iii) X + Y
(iv) XY
X be the random variable which denotes the longest string of heads which
occurs. Find the distribution, expectation, variance and standard
deviation of X.
6 - 21
CHAPTER 6: PROBABILITY CS218
40. A player tosses two fair coins. He wins $1 if 1 head appears, $2 if 2 heads
appear. On the other hand he loses $5 if no heads appear. Determine the
expected value E of the game and if it is favourable to the player.
u Binomial distribution
41. Find
(i) b( 2 ; 5, 13 )
(ii) b( 3 ; 6, 12 )
(iii) b( 3 ; 4 , 41 )
42. A fair coin is tossed three times. Find the probability P that there will
appear
45. How many dice must be thrown so that there is a better than even chance
of obtaining a six?
6 - 22
CS218 CHAPTER 6: PROBABILITY
(i) If he fires 7 times, what is the probability P of his hitting the target
at least twice?
(ii) How many times must he fire so that the probability of his hitting
the target at least once is greater than 23?
u Miscellaneous problems
(i) P( A ∪ B )
(ii) P( A c ) and P(B c )
(iii) P( A c ∩ B c )
(iv) P( A c ∪ B c )
(v) P( A ∩ B c )
(vi) P(B ∩ A c )
49. Find the probability p of an event if the odds that it will occur are a : b,
that is “a to b”.
50. A die is tossed 100 times. The following table lists the six numbers and
frequency with which each number appeared:
Number 1 2 3 4 5 6
Frequency 14 17 20 18 15 16
51. In a certain college, 25% of the students failed mathematics, 15% of the
students failed chemistry, and 10% of the students failed both
mathematics and chemistry. A student is selected at random.
6 - 23
CHAPTER 6: PROBABILITY CS218
(i) P( A | B )
(ii) P( B | A )
(iii) P( A ∪ B )
(iv) P( A c | B c )
(v) P( B c | A c )
53. Find P( B | A ) if
(i) A is a subset of B
57. A coin is tossed 10 times. In each case, the outcome H (for head), or T (for
tail) is recorded.
(i) What is the total number of possible outcomes of the coin-tossing
experiment?
(ii) In how many of the possible outcomes are exactly five heads
obtained?
(iii) In how many of the possible outcomes are at least nine heads
obtained?
(iv) In how many of the possible outcomes are at most one head
obtained?
(v) In how many of the possible outcomes are at least one tail obtained?
6 - 24
CS218 CHAPTER 6: PROBABILITY
61. A suitcase contains five pink, four grey, and three blue socks. Three socks
are drawn without replacement. Consider the following events
A: at least one pink sock is drawn
B: exactly two pink socks are drawn
C: one sock of each colour is drawn
(i) Which events are mutually exclusive? Explain.
(ii) Which events are not mutually exclusive? Explain.
(iii) Calculate the probabilities of A, B, and C
62. Given two events E1 and E2, state the conditions for the events to be
(i) independent
65. Two ordinary dice are thrown, giving the individual scores p and q each
ranging from 1 to 6:
(i) What is the probability that the sum of p and q is exactly 6?
(ii) What is the probability that p = q?
(iii) What is the probability that p = q and p + q = 6?
(iv) What is the probability that p = q or p + q = 6?
6 - 25
CHAPTER 6: PROBABILITY CS218
66. A single dice is thrown eight times; each time, either 0 or 1 is written
down: we write 0 if the score is between 1 and 5; we write 1 if the score is
6.
(i) What is the probability that the resulting bit sequence contains
seven consectutive 0’s?
(ii) What is the probability that the resulting bit sequence contains 5
consecutive 0’s?
67. In a lucky draw, you win a computer and a software package. The
computer is either a PC or a Macintosh. There are four software
packages, three of which will run only on the PC. What is the probability
that you have won a compatible pair?
6 - 26
CHAPTER 7: GRAPH THEORY
Chapter Objectives
7-1
CHAPTER 7: GRAPH THEORY CS218
7.1.1 GRAPHS
u A graph is just a set of points called vertices connected by lines called edges.
u Graphs are denoted by uppercase letters like G and H. The set of vertices of a graph G
is denoted by V(G), and the set of edges of a graph G is denoted by E(G).
u A single element from the set of vertices is called a vertex. Vertices will be denoted
by lowercase letters.
u An edge is denoted by listing the vertices that are its endpoints. When naming the
edge the order of the vertices is not important, e.g. edge db is the same as edge bd.
u If there is an edge joining a pair of vertices, those vertices are said to be adjacent.
Otherwise, they are nonadjacent.
u An edge is incident with a vertex if the edge is joined to the vertex. Therefore, an
edge is incident with its endpoints.
u The number of edges connected to a given vertex is called the degree of that vertex.
The degree of a vertex is denoted d(v). The degree sequence of a graph is the list of
the degrees of its vertices in non-increasing order.
u An edge contributes 1 to the degree of each of its two endpoints. This fact gives us the
following theorem.
7-2
CS218 CHAPTER 7: GRAPH THEORY
u A multigraph allows more than one edge between a pair of vertices. Such edges are
called multiple edges.
u A pseudograph allows loops and multiple edges. A loop is an edge that connects a
vertex to itself.
7.1.3 DIGRAPHS
u A graph whose edges are all directed is called a directed graph or digraph. The
directed edges are called arcs.
u In a digraph parallel arcs are pairs of arcs in which one is directed from vertex a to
vertex b and the other in directed from vertex b to vertex a. They are distinct arcs and
are denoted ab and ba respectively. So the order in which we list the vertices of an arc
is important.
Digraph H
u The indegree of a vertex v is the number of arcs directed toward v and is denoted
id(v)
u The outdegree of v is the number of arcs directed away from v and is denoted od(v).
7-3
CHAPTER 7: GRAPH THEORY CS218
u Notice that each arc contributes 1 to the indegree of the vertex it points to and 1 to the
outdegree of the vertex it points away from. This gives the following theorem:
l Theorem 2: In a digraph, the sum of the indegrees equals the sum of the
outdegrees.
Example 1: In graph G, c, e, b is a
path of length 2 between c and b.
The edges of the path are ce and eb
u A graph that is disconnected contains two or more pieces, called components of the
graph.
7-4
CS218 CHAPTER 7: GRAPH THEORY
7.2.1 SUBGRAPHS
u A subgraph A of graph B has as its vertex set a subset of the vertices of B, and as its
edge set a subset of the edges of B.
Graph C is a subgraph of graph B: A subgraph need not contain all the vertices
of the original graph.
Graph F is a subgraph of graph B: A subgraph need not contain all the edges of
the original graph.
Example 7: Suppose you are asked to draw the graph G with vertex set
V (G ) = {a , b , c, d , e} and edge set E (G ) = {ab , ac, bc, bd , ce}. It is possible to
draw this graph in many different ways. For instance:
u Graphs G and H are isomorphic if they can be labelled so that u and v are adjacent in
G iff the corresponding vertices are adjacent in H.
u G and H are isomorphic if there exists a , 1− 1onto function between their vertices that
preserves adjacency. This function is called an isomorphism.
7-5
CHAPTER 7: GRAPH THEORY CS218
Example 8: Describe a function that shows the graphs G1 and G 2 are isomorphic.
Example 9: Describe a function that shows the graphs G 3 and G 4 are isomorphic.
5. The length of the shortest path between pairs of vertices with a given
degree
7-6
CS218 CHAPTER 7: GRAPH THEORY
Example 10: There are five nonisomorphic graphs with degree sequence 3, 3, 2,
2, 1, 1. Draw them and explain why they are not isomorphic to
one another.
Notice that four of the graphs are connected, while graph e has 2
components. In other words graph e is not isomorphic to any of the
other graphs as it has 2 components, i.e. is not connected.
In order to see why the other graphs are not isomorphic we focus on the
length of the shortest path between the two vertices of degree 1. In
graph a this length is 2, in graph b this length is 3, and in graphs c and
d the length is 4. This shows that graphs a and b are not isomorphic to
any of the other graphs.
We now need to show that graph c and d are not isomorphic to each
other. The longest path in graph c has length 4, while the longest path
in graph d has length 5. So graph c and d are also not isomorphic.
7.3.1 TREES
1. G is a tree
7-7
CHAPTER 7: GRAPH THEORY CS218
u A tree is a special type of bipartite graph. A graph is bipartite if its vertices can be
separated into two sets A and B, so that vertices within the same set are nonadjacent.
u A bipartite graph is drawn with the vertices of A on the left and vertices of B on the
right, or vertices of A at the top and vertices of B at the bottom.
u Note that the vertices that are adjacent are between vertices of the set A and vertices
of the set B. There are no adjacent vertices within the sets A or B.
4. Repeat steps 2 & 3 until you have labelled all vertices with
a distinct label (bipartite) or you have a conflict, i.e. you
have to label a vertex with a and b. (not bipartite)
Example 11: Label each graph to determine if it is bipartite. For those that are
bipartite, redraw them showing the vertex sets A and B of the
definition.
graph a graph c
7-8
CS218 CHAPTER 7: GRAPH THEORY
l Remark 10: G is bipartite iff G does not contain any odd cycles.
u A complete bipartite graph is one in which each vertex in set A is adjacent to every
vertex in set B.
l Remark 11: The complete graph K n has n vertices, with every vertex
connected to every other vertex.
u C n is 2-regular
7-9
CHAPTER 7: GRAPH THEORY CS218
u A plane graph is a graph drawn in the plane (a flat surface) having on edges
crossing.
u In a plane graph, each cycle not containing any smaller cycles encloses a region called
a face. The region exterior to the graph is called the infinite face.
u Let f be the number of faces (including the exterior face), e be the number of edges,
and n be the number of vertices in a plane graph.
Example 13: Redraw the following graphs with as few edge crossings as possible.
For any plane graphs you draw, verify Euler’s formula.
Graph a is a plane graph and there are 6 vertices, 9 edges, and 5 faces. Thus
n − e + f = 6 − 9 + 5 = 2. Graph c is a plane graph also and there are 7 vertices, 13
edges, and 8 faces. Thus n − e + f = 7 − 13 + 8 = 2
u Graphs are represented on a computer using matrices. Some matrices are used to
represent graphs, while others are used to describe properties of graphs.
u A (0, 1)-matrix is a matrix each of whose entries is 0 or 1. The identity matrix and
the zero matrix are examples of (0, 1)-matrices.
1 if v i v j is an edge of G
a ij =
0 otherwise
u Since a vertex is never adjacent to itself, A(G) has 0’s on the diagonal.
7 - 10
CS218 CHAPTER 7: GRAPH THEORY
v1 v2 v 3 v4 v 5
v1 0 1 1 0 1
v2 1 0 1 0 1
1 0 0 0
A (G ) = v3 1
v4 0 0 0 0 1
v5 1 1 0 1 0
u A lot of the time a graph does not come conveniently labelled. The graph can have
labels other than v1 , v2 ,K , vn or it may have no labels at all. In either case just
arbitrarily assign labels v1 , v2 ,K , vn to the n vertices of the graph. Different label
assignments will produce different matrices.
u With bipartite graphs however we will always label all the vertices of side A first then
the vertices of side B. This labelling will be the only acceptable labelling format. (To
ensure ease of grading)
123 4 5
1 0 1 0 0 0
2 1 0 1 1 0
1 0 1 1
A (G ) = 3 0
4 0 1 1 0 0
5 0 0 1 0 0
Example 16: From the adjacency matrix A(H) construct the graph H.
0 1 0 1
1 0 1 1
A (H ) =
0 1 0 0
1 1 0 0
First labelling the rows and columns of the matrix 1, 2, 3, 4 helps us to obtain
the graph H
1 23 4
1 0 1 0 1
2 1 0 1 1
A (H ) =
3 0 1 0 0
4 1 1 0 0
7 - 11
CHAPTER 7: GRAPH THEORY CS218
u Suppose G has vertex set V (G ) = {v1 , v2 ,K , vn } and edge set E (G ) = {e1 , e2 ,K , e m }. The
incidence matrix M(G) is the n × m (0,1)-matrix defined by:
1 if vi is an endpoint of e j
m ij =
0 otherwise
u Since an edge has two endpoints, there are two 1’s in each column of M(G)
u Each 1 in row i of M(G) corresponds to an edge incident with vi . Thus, the number of
1’s in row i is the degree of vi
e1 e2 e3 e4 e5 e6 e7 e8
v1 1 1 1 0 1 0 0 0
v2 1 0 0 1 0 0 0 0
1
M = v3 0 0 1 1 0 0 1
v4 0 0 0 0 1 1 0 1
v5 0 1 0 0 0 1 1 0
u The distance between vi and v j , denoted d ij , is the length of the shortest path
connecting vi and v j . If G is connected, d ij is finite for every pair vi , v j . When G is
disconnected, d ij = ∞ for vertices in distinct components and is finite otherwise.
Example 18: Find the distance matrix for the graphs G and H.
v1 v2 v3 v4 v5 u1 u 2 u 3 u 4 u 5
v1 0 1 2 2 3 u1 0 ∞ ∞ 2 1
v2 1 0 1 1 2 u 2 ∞ 0 1 ∞ ∞
1 1 ∞
D (G ) = v3 2 1 0 D( H ) = u3 ∞ 1 0 ∞
v4 2 1 1 0 2 u4 2 ∞ ∞ 0 1
v5 3 2 1 2 0 u5 1 ∞ ∞ 1 0
7 - 12
CS218 CHAPTER 7: GRAPH THEORY
u An interesting part of graph theory is the puzzle in which you try to draw a given
figure without taking your pencil off the paper, and without drawing over a line.
Example 19: See if you can draw each of the graphs below without taking your
pencil off the paper. Before starting, a warning: Only two of them
can be drawn in this manner, and it may matter where you start.
u Now lets look at a theorem that tells us exactly which figures we can draw without
taking a pencil off the paper. First some definations:
u A trail is a walk in which the edges (but not necessarily the vertices) are distinct.
u If the trail begins and ends at the same vertex, it is said to be closed.
7 - 13
CHAPTER 7: GRAPH THEORY CS218
Example 20: Find an Eulerian trail in each of the graphs from example 19, if
possible. Which of the graphs is Eulerian?
u How can one tell if a graph is Eulerian? The answer is contained in the Euler
theorem.
l Euler Theorem:
(i) A connected graph is Eulerian iff each vertex has an even degree.
(ii) A connected graph is semi-Eulerian but not Eulerian iff the graph
contains precisely two vertices having odd degree. Furthermore, the
Eulerian trail must begin at one of the odd vertices and end at the
other.
u To find a closed Eulerian trail in an Eulerian graph use the following algorithm.
Starting at vertex f, we record and erase the edges in the trail f, g, m. At this
point fm is a bridge and there is an alternative. Use the alternative, thus f, g,
m, v is are trail so far. Now however, vk is a bridge but there is no alternative,
so we use it. Thus, are trail is f, g, m, v, k, i, g, h, i, j, k, m, f
7 - 14
CS218 CHAPTER 7: GRAPH THEORY
A Hamiltonian cycle in H is g, h, i, j, k, p, t, o, s, n, r, m, q, v, w, x, y, z, u, g
7 - 15
CHAPTER 7: GRAPH THEORY CS218
Example 24: Find a minimum-weight Hamiltonian cycle for the weighted graph
below.
a, b, c, d, e, f, a has weight 28
a, b, d, e, f, c, a has weight 26
a, b, e, d, c, f, a has weight 30
a, c, b, d, e, f, a has weight 26
a, c, d, b, e, f, a has weight 28
u As you can see the travelling salesman problem is difficult, even for a small problem.
Unfortunately, there is no efficient method for solving the travelling salesman
problem.
7 - 16
CS218 CHAPTER 7: GRAPH THEORY
7.6 SUMMARY
7.6.1 THEOREMS
l In a graph G, the sum of the degrees of the vertices equals twice the number of
edges.
l Corollary: The sum of the degrees of the vertices of a graph is an even number.
l In a digraph, the sum of the indegrees equals the sum of the outdegrees.
l Euler’s formula: In a connected plane graph with f faces, e edges, and n
vertices, we have the relationship: n − e + f = 2
l Euler Theorem:
(i) A connected graph is Eulerian iff each vertex has an even degree.
(ii) A connected graph is semi-Eulerian but not Eulerian iff the graph
contains precisely two vertices having odd degree. Furthermore, the
Eulerian trail must begin at one of the odd vertices and end at the other.
l Fleury’s Algorithm: Suppose a graph is Eulerian. To find an Eulerian trail,
begin at any vertex. Record and erase each edge as it is
used, subject to the following condition: Never use a
bridge unless there is no alternative.
7.6.2 REMARKS
l Some items to check when trying to show that a pair of graphs are not isomorphic
are:
5. The length of the shortest path between pairs of vertices with a given
degree
7 - 17
CHAPTER 7: GRAPH THEORY CS218
1. G is a tree
5. G contains no cycles, but the addition of any edge to G will produce a single
cycle.
l A simple labelling procedure determines whether G is bipartite:
3. Next, label all vertices that are adjacent to a vertex just labelled b with label a
4. Repeat steps 2 & 3 until you have labelled all vertices with a distinct label
(bipartite) or you have a conflict (not bipartite)
l G is bipartite iff G does not contain any odd cycles.
l The complete graph K n has n vertices, with every vertex connected to every other
vertex.
l In Hamiltonian problems, one passes through each vertex exactly once. In
Eulerian problems one passes through each edge exactly once.
7 - 18
CS218 CHAPTER 7: GRAPH THEORY
5. V (G ) = {a , b , c, d } E (G ) = {ab , cd , bd , bc}
7. V ( M ) = {k , m, n , p , q , r} E ( M ) = {km, mp , kp , qr}
13. A vertex having outdegree 0 is called a receiver; list all the receivers
7 - 19
CHAPTER 7: GRAPH THEORY CS218
u Explain
14. Why is it easy to spot a vertex that is both a transmitter and a receiver?
23. Determine what the length of each path between a and b is.
28.
29.
30.
7 - 20
CS218 CHAPTER 7: GRAPH THEORY
u Give a function to show that each of the pairs of graphs are isomorphic.
31.
32.
33.
34. 3, 3, 2, 1, 1, 1, 1 35. 4, 2, 2, 1, 1, 1, 1
36. 3, 2, 1, 1, 1, 1, 1 37. 5, 3, 2, 2, 2, 1, 1
54. Two 3-reqular graphs on six vertices (be sure they are not isomorphic)
7 - 21
CHAPTER 7: GRAPH THEORY CS218
u Show that
73. Verify Euler’s formula for the graphs that are planar.
7 - 22
CS218 CHAPTER 7: GRAPH THEORY
89. Use Euler’s theorem to determine which graphs are Eulerian or semi-
Eulerian.
90. List an Eulerian trail for each Eulerian graph and each semi-Eulerian
graph.
92. List a Hamiltonian cycle for each Hamiltonian graph, and list a
Hamiltonian path for each semi-Hamiltonian graph.
7 - 23
CHAPTER 7: GRAPH THEORY CS218
110.
Solve the Traveling Salesman problem for each graph.
111. K4
112. K 2,3
u Show that the following pairs of graphs are not isomorphic by finding an isomorphic
invariant they do not share.
113.
114.
7 - 24
CS218 CHAPTER 7: GRAPH THEORY
115. Show that the two graphs are isomorphic by finding the two functions
g :V (G ) → V (G ' )
h: E (G ) → E (G ' )
u Redraw the following bipartite graphs, so that their bipartite natures are evident.
116.
0 1 0 1 0
1 0 0 1 1
0 0 0 1 1
117.
1 1 1 0 1
0 1 1 1 0
0 1 1 0 1
1 0 1 0 1
1 1 0 0 0
118.
0 0 0 0 1
1 1 0 1 0
7 - 25
CHAPTER 7: GRAPH THEORY CS218
u Miscellaneous problems.
127. Find a formula in terms of m and n for the number of edges of K m,n .
Explain.
129. Find the adjacency matrix and the distance matrix corresponding to the
following graph F:
a
d
b
e
c
131. How would you attempt to show that two graphs are isomorphic?
132. How whould you attempt to show that two graphs are not isomorphic?
List the stuctural properties you would have to consider.
a b p q
c
e d
t s
G
H
7 - 26
CHAPTER 8: MATRICES
Chapter Objectives
8-1
CHAPTER 8: MATRICES CS218
8.1 MATRICES
u A matrix is a rectangular table of numbers. The numbers are called entries (or
elements) of the matrix.
u The dimension of the matrix is the number of rows and columns it contains. The
dimension is written in the form:
6 −
1 3
Example 1: For the matrix A = 4 2 5 list a 23 , a 31 , and a 12
7 1 8
a 23 is the entry in the second row and third column of A. Thus a 23 = 5. Similarly,
a 31 = 7, and a12 = − 1
a b 6 3
Exercise 1: If A = and B = and A = B what are the values of a, b, c,
c d 9 5
and d?
8-2
CS218 CHAPTER 8: MATRICES
2 − 1 4 3 5 − 1 1 1 − 4
Example 2: If A = − , B = , and C =
3 7 10 12 2 6 2 8 17
a. A + B b. A − C c. 3B d. A + 2B − C e. B + 5C
2 − 1 4 3 5 − 1 2 + 3 − 1+ 5 4 + ( − 1) 5 4 3
a. A + B = − + = − =
3 7 10 12 2 6 3 + 12 7 + 2 10 + 6 9 9 16
2 − 1 4 1 1 − 4 2 − 1 − 1− 1 4 − ( − 4 ) 1 −
2 8
b. A − C = − − = − = −
3 7 10 2 8 17 3 − 2 7 − 8 10 − 17 5 7
− −
1
3 5 − 1 3 ⋅ 3 3 ⋅ 5 3( − 1 ) 9 15 − 3
c. 3B = 3 = =
12 2 6 3 ⋅ 12 3 ⋅ 2 3 ⋅ 6 36 6 18
2 − 1 4 3 5 − 1 1 1 − 4
d. A + 2B − C = − +2 −
3 7 10 12 2 6 2 8 17
2 + 6 − 1 − 1+ 10 − 1 4 − 2 + 4 7 8 6
= − =
3 + 24 − 2 7 + 4 − 8 10 + 12 − 17 19 3 5
− − − −
3 5 1 1 1 4 3 + 5 5 + 5 1− 20 8 10 21
e. B + 5C = +5 = =
12 2 6 2 8 17 12 + 10 2 + 40 6 + 85 22 42 91
− 5 8 4 7
Example 3: Find D so that 2D + = −
1 3 1 5
−
x y
D must be a 2 × 2 matrix, so let D =
z w
2 x − 5 2 y + 8 4 7
−
x y 5 8 4 7
Then 2 + = − yields = −
z w 1 −
3 1 5 2 z + 1 2w − 3 1 5
9 −1
Therefore, D = −2 2
1 4
8-3
CHAPTER 8: MATRICES CS218
a. k ( A + B ) = kA + kB
b. ( k + h ) A = kA + hA
a. A +0= A
b. k ⋅0= 0
c. 0⋅ A = 0
u A vector is a list of numbers. If the list is written horizontally in a row then it is called
a row vector. If the list is written vertically in a column then it is called a column
vector.
u A row vector with n entries is a 1× n matrix, and a column vector with m entries is an
m×1 matrix.
−
Example 4: An example of a row vector is v = [15 3 4]
15
Example 5: An example of a column vector is v = − 3
4
l Remark 1: A column vector is not equal to a row vector even if there entries
are the same.
u A matrix is a square matrix if the number of rows equals the number of columns.
u The diagonal of a matrix A consists of all the entries a ii , that is, the entries whose
row and column numbers are equal.
u A diagonal matrix is a square matrix is a square matrix whose only nonzero entries
are diagonal entries. That is, a ij = 0 if i ≠ j
u The identity matrix of order n is the n × n matrix having 1’s on the diagonal and 0’s
elsewhere. The identity matrix is denoted by I n
u The zero matrix is an m × n matrix in which all the entries in the matrix are zero. The
zero matrix is denoted by 0 mn
8-4
CS218 CHAPTER 8: MATRICES
1 2 3
Example 6: Find the diagonal of the matrix A = 4 5 6
7 8 9
Matrix A is a square matrix since the number of rows is three and the number
of columns is three also. The diagonal of matrix A is the numbers 1, 5, and 9
1 0 0 0
0 1 0 0
Example 7: The matrix is the identity matrix I
0 0 1 0
0 0 0 1
0 0 0 0
Example 8: The matrix 0 0 0 0 is the zero matrix 0 34
0 0 0 0
Matrix Multiplication
1. In order to multiply AB, the number of columns of A must
be equal to the number of rows of B. The answer matrix
will have the same number of rows as A and the same
number of columns as B.
− 9
Example 9: What is [ 2 5] ?
4
− 9 9 −
[2 5] = 2 ⋅ 9 + ( − 5 ) ⋅ 4 = 18 − 20 = − 2. Thus [ 2 −
5] = [ 2]
4 4
8
Example 10: What is [ 3 7 2] − 1 ?
6
8 8
[ 3 7 2] 1 = 3 ⋅ 8 + 7 ⋅ ( 1) + 2 ⋅ 6 = 24 − 7 + 12 = 29. Thus [ 3 7 2] − 1 = [ 29]
− −
6 6
l Remark 4: For the product AB to be defined, the middle two numbers must
be equal.
8-5
CHAPTER 8: MATRICES CS218
a. A is 4 × 3 and B is 3 × 2 b. A is 3 × 2 and B is 3 × 2
c. A is 2 × 4 and B is 4 × 4 d. A is 3 × 1 and B is 1× 2
11 8
3 1
Example 11: Calculate 5 − 2 −
2 6
16 4
8-6
CS218 CHAPTER 8: MATRICES
3 12
A = 1 7
t
−
5 6
a. The transpose has dimension 3 × 4, and the rows of the transpose correspond
to the columns of the given matrix. Thus, we have
5 −
3 3 15
−1 0 1 − 2
9 2 6 8
b. First apply the transpose operation. The t applies only to the second matrix
(the row vector that becomes a column vector). We then multiply:
1
2 1 7 2 1 7 ( 2 ⋅ 1) + (1⋅ 2 ) + ( 7 ⋅ 6 ) 46
[ 1 2 6] t
= 2 = =
8 3 4 8 3 4 ( 8 ⋅ 1) + (( − 3 ) ⋅ 2 ) + ( 4 ⋅ 6 ) 26
− −
6
1. ( A t )t = A
2. ( A + B )t = A t + B t
3. ( AB ) t = B t A t
4. ( kA ) t = kA t
8-7
CHAPTER 8: MATRICES CS218
8.2 SUMMARY
8.2.1 REMARKS
l A column vector is not equal to a row vector even if there entries are the same.
l In order to multiply two matrices the number of columns in the first matrix
(vector) must be equal to the number of rows in the second matrix (vector)
l If you can multiply two matrices, the answer is a matrix, not a number.
l For the product AB to be defined, the middle two numbers must be equal.
l If the middle numbers of AB are equal, the dimension of AB is given by the two
outside numbers
l Matrix A is symmetric if A = A t
8-8
CS218 CHAPTER 8: MATRICES
u Evaluate:
3 12 5 −
5 3 1
2 − 1 3 8 11 − 15
1. − 1 + 3 2. + − − 3. − 2 3 − 2 7 −
2
− 0 5 7 2 3 9 −
10 2 0 1 8 5
4 2 7 2 1 − −
4. − 5. [ 5 2 8 4] + [ 2 7 5]
13
−
5 8 10 0
−5 2 3 −
6 13 − 2
u For A = − 1 0 B = 0
1 and C = 11 9 evaluate:
− −
2 6 5 8 7 1
6. B − 2 A 7. C + 3 A − B 8. A + C
−
9. 4A 10. 1
2 A + 32 B . A + 0.2B − 0.3C
11. 01
2x + 5 11 x + 3 5x + 1 10
16. = 17. + = −
y − 3 7 2 y + 1 4 y − 2 4
3x + 4 4 x − 6 4 x − 3 y 8
−
18. = 19. =
5 y + 2 3 y + 16 x + 2 y 9
x + 2 y 9
x + 2 y − 5 12
−
12 − 1
3 − 3 1 4 7 8
22. − 23. 24. 3 6 25. [ 5 5 −
1 0]
8 1 2 3 1 11
−
−
2 2
8-9
CHAPTER 8: MATRICES CS218
u A company has three factories. Their production output is listed in the following
matrix with the columns representing the four weeks in February:
26. How many items did factory 3 produce in the second week of February?
27. How many items did factory 1 produce in the last week of February?
28. What was factory 2’s total output for the month?
29. How many items did the company produce during the second week of
February?
8 − 1 − 3 7
u For the matrix A = − 3 9 4 2 list
−
0 1 2 5
u Find:
−
1 3 4 − 21 5 − 9
34. A matrix E so that 5E − − =
3 1 7 8 11 43
2
5 − 7 11 12
3 −
5 6 1 2 4
35. 8 11 36. − 3 0 − 37. [ 5 8 − 1 10] −
2 0 − 4 −
3 12 3
0 2 5 6
17
u Simplify:
− − 5 4
4 3 3 8 17
42. − 3 − 2 + −
1 0 4 − 10 31
1 0
− −
1 3 5 7
43. [ − 7 12] − − [ 9 − 10 11 − 12]
2 4
−
6 8
1 2 2 3
u Let A = − and B = −
4 1 2 5
8 - 10
CS218 CHAPTER 8: MATRICES
u Find:
2 3 − 5 0
u Let A = − and B =
5 1 8 6
50. What do you know about the sizes of the matrices A and B if both of the
products AB and BA are defined?
8 - 11
APPENDIX A: GLOSSARY
The following are some of the terms you should be familiar with, or will
encounter during your study of discrete mathematics. You are not
required to memorize these terms. They are presented here to help your
understanding of discrete mathematics.
A-1
APPENDIX A: GLOSSARY CS218
GLOSSARY
u A
Absolute value of a real number: The absolute value of a, written |a|, is the
nonnegative number which is equal to a if a is nonnegative and equal to −a if a is
negative.
Additive inverse: The additive inverse of a number a is the number −a for which
a + (−a ) = 0.
u B
Biconditional: A biconditional is an equivalence formed from two given
propositions by connecting them by “if, and only if.” An equivalence is true if both
propositions are true, or if both are false. The equivalence formed from propositions
p and q is usually denoted by p ↔ q, or p ≡ q.
Bridge: In a graph G, a bridge is an edge whose removal will increase the number of
components in the graph.
u C
Cardinal (cardinal number): A number which designates the manyness of a set of
things; the number of units, but not the order in which they are arranged; used in
distinction to signed numbers.
Cartesian product: The Cartesian product of two sets A and B is the set (denoted
by A × B) of all pairs ( x, y ) such that x is a member of A and y is a member of B.
Circuit: A closed walk that does not contain a repeated edge. See trail.
A-2
CS218 APPENDIX A: GLOSSARY
Closed walk: A walk that begins and ends at the same vertex.
Complement of a set:The set of all objects that do not belong to the given set U, but
belong to a given whole space (or set) that contains U.
Complete graph: A graph in which any two distinct nodes are joined by exactly one
edge.
Compound event: Suppose S 1 and S 2 are sampe spaces for the outcomes of two
experiments and that E1 and E 2 are events contained in S 1 and S 2 , respectively. Then
the Cartesian product E1 × E 2 is a compound event.
Connected graph: A graph is connected if any two nodes can be joined by moving
along edges, otherwise it is disconnected.
A-3
APPENDIX A: GLOSSARY CS218
both false. The contrapositive of an implication is the converse of the inverse (or the
inverse or the converse) of the implication.
Cycle: In a graph G is a path that begins and ends at the same place.
u D
Dependent events: Two events are dependent if they are not independent.
Disjoint: Two sets are disjoint if there is no object which belongs to each of the sets
(i.e., if the intersection of the sets is the null set).
Difference of sets: The difference A − B of two sets A and B is the set of all objects that
belong to A and do not belong to B.
Direct proof: A direct proof uses an argument that makes direct use of the
hypotheses and arrives at the conclusion.
Directed line (directed edge): A line (or line segment) on which the direction from
one end to the other has been indicated.
Disjoint: Two sets are disjoint if there is no object which belongs to each of the sets
(i.e., if the intersection of the sets is the null set).
Domain: The domain of a function is the set of values which the independent
variable may take on, or the range of the independent variable.
u E
Edge: A line or a line segment which is the intersection of two plane faces of a
geometric figure, or which is the boundary of a plane figure.
Elurian circuit: Let G be a graph. AnEulerian circuit for G is a circuit that contains
every vertex and every edge of G. That is, an Eulerian circuit for G is a sequence of
adjacent vertices and edges in G that starts and ends at the same vertex, uses every
vertex of G at least once, and uses every edge of G exactly once.
Elurian path: Let G be a graph and let v and w be two vertices of G. An Eulerian
path from v to w is a sequence of adjacent edges and vertices that starts at v, ends at
w, passes through every vertex of G at least once, and traverses every edge of G
exactly once.
A-4
CS218 APPENDIX A: GLOSSARY
Equality: The relation of being equal; the statement, usually in the form of an
equation, that two things are equal.
Equivalent: Two objects that are so related that they are ‘similar’ in such a way that
they can be said to be equal.
Even number: An integer that is divisible by 2. All even numbers can be written in
the form 2n, where n is an integer.
u F
Finite geometric sequence: The general form of a finite geometric sequence is
{a , ar, ar 2 , ar 3 ,L , ar n−1}, where a is the first term, r is the common ratio, and ar n−1 is
a (1− r n )
the last term. The sum of the terms is .
1− r
Finite set: A set which contains a finite (limited) number of members; a set which
has, for some integer n, just n members.
Function: An association of exactly one object from one set (the range) with each
object from another set (the domain).
u G
Geometric sequence: A geometric sequence is a sequence for which the ratio of a
term to its predecessor is the same for all terms.
u H
Hamiltonian circuit: Given a simple graph G, a Hamiltonian circuit for G is a
simple circuit that includes every vertex of G. That is, a Hamiltonian circuit for G is a
A-5
APPENDIX A: GLOSSARY CS218
sequence of adjacent vertices and distinct edges in which every vertex of G appears
exactly once, and that starts and ends at the same vertex.
Hamiltonian path: Given a graph G and letting v and w be two vertices of G, then a
Hamiltonian path is a path starting a v and ending at w in which every vertex of graph
G appears exactly once.
u I
Image: If A is a subset of the domain of f, then the image of A is denoted by f ( A ) and
is the set of all images of members of A.
Implication: (1) A statement that follows from other given statements. (2) A
proposition formed from two given propositions by connecting them in the form “ IfL,
then L.” The first statement is the antecedent (or bypothesis) and the second is the
consequent (or conclusion). An implication is true in all cases except when the
antecedent is true and the consequent is false. For propositions p and q, the
implication “if p, then q” is usually written as p → q, and is read “p implies q.”
Incidence function: A function defined on the set of edges that assigns to each
directed edged exactly one ordered pair of nodes and to each undirected edge exactly
one unordered pair.
Indirect proof: An indirect proof shows that it is impossible for that which is to be
proved to be false, because if it is false some accepted facts are contradicted; in other
words, it assumes the negation of the proposition to be proved and then shows that
this leads to a contradiction.
Induction: A method of proving a law or theorem by showing that it holds in the first
case and showing that, if it holds for all the cases preceding a given one, then it holds
for this case. Before the method can be applied it is necessary that the different cases
of the law depend upon a parameter which takes on the values 0, 1, 2, 3, …. The
essential steps of the proof are as follows: (1) Prove the theorem for the first case. (2)
Prove that if the theorem is true for the nth case (or for the first through nth cases),
then it is true for the ( n +1)th case. (3) Conclude that it must then be true for all cases.
For, if there were a case for which it is not true, there must be a first case for which it
is not true. Because of (1) this is not the first case. But because of (2), it cannot be any
other case [since the previous case could not be true without the next case (known to
be false) being true; it could not be false because the next case is the false case].
Infinite set: A set which is not finite; a set which has an unlimited number of
members; a set which can be put into one-to-one correspondence with a proper part of
itself.
A-6
CS218 APPENDIX A: GLOSSARY
Intersection: The intersection of two sets consists of all the points that belong to
each of the sets. The intersection of sets U and V usually is denoted by U ∩ V .
Inverse image: The inverse image (pre-image) of a set B contained in the range of f
is denoted by f −1 ( B ) and is the subset of the domain whose members have images in
B. In particular, the inverse image of a point y in the range is the set of all x for which
f ( x ) = y.
Inverse of an implication: The implication which results from replacing both the
antecedent and the consequent by their negations. The converse and the inverse of an
implication are equivalentthey are either both true or both false.
Irreflexive: A relation such that x does not bear the given relation to itself for anyx.
u J
u K
u L
Logically equivalent: Two statements are logically equivalent if they are
equivalent because of their logical form rather than because of mathematical
content.
u M
Mathematical induction: See induction.
u N
Natural numbers: The positive integers. 1, 2, 3, …
Negation: The proposition formed from the given proposition by prefixing “It is
false that,” or simply “not.” The negation of a proposition p is frequently written as
A-7
APPENDIX A: GLOSSARY CS218
~p and read “not p.” The negation of a proposition is true if and only if the
proposition is false.
Negation: The proposition formed from the given proposition by prefixing “It is
false that,” or simply “not.” The negation of a proposition p is frequently written as
~p and read “not p.” The negation of a proposition is true if and only if the
proposition is false.
Node: A dot.
u O
Odd integer: A number that is not evenly divisible by 2; any number of the form
2n + 1, where n is an integer.
Ordered pair: A set with two (possibly equal) terms for which one term is
designated as the first and the other as the second.
u P
Pairwise disjoint: A system of more than two sets is pairwise disjoint if each pair of
sets belonging to the system is disjoint.
Parallel arcs: Directed lines in which one is directed from vertex v to vertex w and
the other is directed from vertex w to vertex v.
Path: A sequence of edges that goes from one edge to another through a common
node, but each edge in the sequence occurs only once.
Plane: A surface such that a straight line joining any two of its points lies entirely in
the surface.
Power set: Given a set A, the power set of A denoted P ( A ) is the set of all subsets of A.
Proof: (1) The logical argument which establishes the truth of a statement. (2) The
process of showing by means of an assumed logical process that what is to be proved
follows from certain previously proved or axiomatically accepted propositions.
A-8
CS218 APPENDIX A: GLOSSARY
Proposition: (1) A theorem or problem. (2) A theorem or problem with its proof or
solution. (3) Any statement which makes an assertion which is either true or false, or
which has been designated as true or false.
u Q
Quantifier: Prefixes such as “for every” or “there are.” Quantifiers precede a
propositional function and may be represented symbolically. See universial
quantifier, existential quantifier.
u R
Range: The range of a function is the set of values that the function takes on.
Reflexive relation: A relation of which it is true that, for any x, x bears the given
relation to itself.
Region: A set that is the union of an open connected set and none, some or all of its
boundary points.
Relation: Equality, inequality, or any property that can be said to hold (or not hold)
for two objects in a specified order.
u S
Sequence: A set of quantities ordered as are the positive integers.
Set: A collection of particular things, as the set of numbers between 3 and 5, the set of
points on a segment of a line, or within a circle, etc.
Simple circuit: A circuit that does not have any other repeated vertex except the
first and the last.
Simple path: A path from v to w that does not contain a repeated vertex.
Subset: If each member of a set A belongs to a set B, then one says that A is contained
in B, B contains A, A is a subset of B, or B is a superset of A.
A-9
APPENDIX A: GLOSSARY CS218
Syllogism: A logical statement that involves three propositions, usually called the
major premise, minor premise, and conclusion, the conclusion necessarily being true
if the premises are true.
Symmetric relation: A relation which has the property that if a is related to b, then
b is related in like manner to a.
u T
Tautology: A tautology is a statement form that is always true regardless of the
truth values of the individual statements substituted for its statement variables.
Trail: A walk in which the edges (but not necessarily the vertices) are distinct.
Transitive relation: A relation which has the property that if A bears the relation
to B and B bears the same relation to C, then A bears the relation to C.
Transpose of a matrix: The matrix resulting from interchanging the rows and
columns in the given matrix.
u U
Undirected edge: A line segment. A line without direction.
Union: The union of of a collection of sets is the set whose members are those objects
that belong to at least one of the given sets. The union of two set U and V is usually
denoted by U ∪ V .
u V
Vertex: A dot. The endpoints in a graph.
u W
Walk: A finite alternating sequence of adjacent vertices from v to w in a graph G.
A - 10
CS218 APPENDIX A: GLOSSARY
Whole number: (1) One of the integers 0, 1, 2, 3, … (2) A positive integer; i.e., a
natural number.
u X
u Y
u Z
Zero of a function: A value of the argument for which the function is zero.
A - 11