Unformatted text preview: Package for MATH 239, Midterm 1
Prepared by Abel Molina1 and Phuong Tran2
June 26, 2011 Contents
1 Enumeration
1.1 Basic tools for enumeration . . . . . . . . .
1.2 Generating functions . . . . . . . . . . . . .
1.3 Properties of generating functions . . . . . .
1.3.1 The Sum Lemma . . . . . . . . . . .
1.3.2 The Product Lemma . . . . . . . . .
1.4 The Binomial Theorem . . . . . . . . . . .
1.5 Recurrences . . . . . . . . . . . . . . . . . .
1.6 Solving problems using generating functions
1.6.1 Partitions of an integer . . . . . . .
1.6.2 Binary strings . . . . . . . . . . . . .
1.6.3 Recursion . . . . . . . . . . . . . . .
1.6.4 Binary trees . . . . . . . . . . . . . .
1.6.5 Bivariate generating functions . . . .
1.7 Homogeneous recurrence relations . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
. .
.
.
.
.
.
.
.
.
.
.
.
.
. .
.
.
.
.
.
.
.
.
.
.
.
.
. .
.
.
.
.
.
.
.
.
.
.
.
.
. .
.
.
.
.
.
.
.
.
.
.
.
.
. .
.
.
.
.
.
.
.
.
.
.
.
.
. .
.
.
.
.
.
.
.
.
.
.
.
.
. .
.
.
.
.
.
.
.
.
.
.
.
.
. .
.
.
.
.
.
.
.
.
.
.
.
.
. .
.
.
.
.
.
.
.
.
.
.
.
.
. 1
1
2
3
4
4
4
5
5
6
7
9
9
10
11 2 Introduction to Graph Theory
2.1 Families of graphs . . . . . . . .
2.2 Graph isomorphism . . . . . . . .
2.3 Adjacency and incidence matrices
2.4 Paths and cycles . . . . . . . . .
2.5 Connectivity . . . . . . . . . . . .
.
.
.
. .
.
.
.
. .
.
.
.
. .
.
.
.
. .
.
.
.
. .
.
.
.
. .
.
.
.
. .
.
.
.
. .
.
.
.
. .
.
.
.
. 11
12
13
14
15
15 .
.
.
.
. .
.
.
.
. .
.
.
.
. .
.
.
.
. .
.
.
.
. .
.
.
.
. 3 Recommended exercises from the problem sets
1
2 [email protected]
[email protected] 1 17 4 Cheat sheet 17 5 Tips for the midterm 18 1 Enumeration The ﬁrst half of the MATH 239 course, which is the one that accounts for
most of the material in the midterm, is the one about enumeration problems.
We will speak about sets of conﬁgurations, each of them with an associated
nonnegative weight. In our problems, we will want to know how many
conﬁgurations are there of an speciﬁc weight. 1.1 Basic tools for enumeration Deﬁnition 1. For anyreal number a and nonnegative integer k , we deﬁne
a
a choose k , denoted k , as
a(a − 1) . . . (a − k + 1)
.
k (k − 1) . . . 1
If a is equal to an integer n, then n is the number of subsets of size k
k
of a set of size n: Proof. Let L be the set of all ordered lists of k distinct numbers from the set
of size n. There are n ways to choose the ﬁrst element, n − 1 ways to choose
the second, and so on, so L = n(n − 1)...(n − k + 1). However, there are
k ∗ (k − 1) ∗ (k − 2) . . . ∗ 1 ways to permute each list of k elements (by choosing
the ﬁrst element, then the second element, and so on). Hence, the number of
1) (n−k
ways to choose subsets of size k from n elements is n(n−(k...1)...1 +1) = n
k
k−
Deﬁnition 2 (Bijective function). A function f : X → Y is bijective if for
each y ∈ Y there is exactly one x ∈ X such that f (x) = y . A way to show that two expressions are equivalent is to associate each
of them with a set, prove that they are equal to the number of elements in
the set, and give a bijection between the sets.
Example 1 (Problem Set 1.4 , 3.a). We want to prove
m+n
k k
m n
=
i
k−i
i=0 Let A and B be disjoint sets of size m and n,
+ respectively. Then, as we
proved when we deﬁned the choose function, mk n is the number of subsets
of size k of A ∪ B .
Similarly, the right hand side is the number of pairs (X, Y ) of sets X ⊆ A
and Y ⊆ B such that X  + Y  = k .
There is a bijection between the subsets of size k of A ∪ B , and the pairs
of subsets of A and B with total size k . This bijection simply splits a subset
S of A ∪ B into two sets, one with the elements of S belonging to A, and the
other with the elements of S belonging to B . The fact that it is a bijection
follows from the fact that every pair (X, Y ) of subsets of A and B with total
size k can be obtained in this way from an unique subset of A ∪ B , X ∪ Y .
Therefore,
k
m+n
m
n
=
.
k
i
k−i
i=0 1.2 Generating functions Generating functions are a way of writing down the answer to a counting
problem. If there are 3 conﬁgurations of weight 0, 5 conﬁgurations of weight
1, 6 conﬁgurations of weight 2 and so on, the generating function for the
problem is 3 + 5x + 6x2 + . . . More formally:
Deﬁnition 3. Let S be a set of conﬁgurations with a nonnegative weight
function w. The generating function for S with respect to w is
ΦS ( x ) = x w (σ ) . σ ∈S Remark 1. By collecting terms with the same power of x, we obtain
ΦS ( x ) = ak xk , k ≥0 where ak is the number of conﬁgurations of weight k .
Remark 2. The coeﬃcient for xk in ΦS (x) can also be denoted as [xk ]ΦS (x).
In case there is a bound on the weights, the generating function will
just be a polynomial. An example is the case in which the conﬁgurations
are the faces of a die, and the corresponding weight is the number of dots
in the face. The generating function is then x + x2 + x3 + x4 + x5 + x6 .
However, in case there is no bound on the weights, the number of terms of this polynomial can be inﬁnite. In that case, we call it a formal power
series. Some important facts about power series are the following ones:
• If A(x) and B (x) are formal power series and B (x) has no constant
term, then A(B (x)) is a formal power series.
• B (x) is the inverse of A(x) iﬀ A(x)B (x) = 1. If B (x) is the inverse of
1
A(x), we write B (x) = A(x) = A(x)−1 .
• A formal power series has an inverse if and only if it has a nonzero
constant term and this inverse is unique.
• The sum of two formal power series
ai xi and
bi xi is equal to
i ≥0
i ≥0
( a i + bi ) x i .
i ≥0 • The product of two formal power series ai xi and i ≥0 bi xi is equal to i ≥0 i
(
aj bi−j )xi . Note that we can also write this as ( i ≥0 j ≥0 • The derivative of a formal power series
(i + 1)ai+1 xi . i≥0 j,k≥0,j +k=i ai xi is equal to a j bk ) x i . i ≥0 i ≥0 1.3 Properties of generating functions • If we evaluate the generating function at x = 1, we obtain the total
number of conﬁgurations.
• If we evaluate the derivative of the generating function at x = 1, we
obtain the sum of the weights over all conﬁgurations.
• From the previous two properties, we obtain that the ratio between
the value of the generating function at x = 1, and the value of the
derivative of the generating function at x = 1, is equal to the average
weight of a conﬁguration. (Note that this only makes sense when the
number of conﬁgurations is ﬁnite, as well as the sum of the weights). 1.3.1 The Sum Lemma Lemma 1. Let A and B be two disjoint sets of conﬁgurations.
their generating functions are ΦA (x) and ΦB (x), the generating
ΦA∪B (x) for A ∪ B is ΦA (x) + ΦB (x). More generally, for any
of conﬁgurations A and B , the generating function ΦA∪B (x) is
ΦA ( x ) + Φ B ( x ) − ΦA ∩B ( x ) . Then, if
function
two sets
equal to Remark 3. This can be extended to the union of more than two disjoint
sets of conﬁgurations (see Exercise 2 in Problem Set 1.4).
1.3.2 The Product Lemma Lemma 2. Let A and B be two sets of conﬁgurations, with generating functions ΦA (x) and ΦB (x). If the weight of a pair (a, b) ∈ A × B is the sum of
the weight of a and the weight of b, then the generating function ΦA×B for
A × B is ΦA (x)ΦB (x).
Remark 4. This can be extended to the cartesian product of more than
two sets of conﬁgurations (see Exercise 3 in Problem Set 1.4). 1.4 The Binomial Theorem Theorem 1 (The Binomial Theorem). For any rational number a,
a
a
(1 + x) =
xk .
k
k ≥0 You do not need to know the proof for general case. However, you should
know the combinatorial proof for the case of nonnegative integer n.
Example 2 (Problem Set 1.8, 8). We want to prove
m−n
n+r−1 m
=
(−1)r
.
t
r
s
r +s= t By the Binomial Theorem, the coeﬃcient for xt in (1 + x)m−n is
However, we can also write (1 + x)m−n as (1 + x)m (1 + x)−n m −n
m
n + r − 1 r
=
xs (−1)r
x,
s
n−1
s≥0 r ≥0 t .
using the formula for −n in the course notes.
r
The coeﬃcient for xt in this new product is, using our deﬁnition for the
product of two formal power series, equal to
m
r n+r−1
(−1)
.
s
n−1
r + s=t
We have then proved the given identity, computing the coeﬃcient of xt
in (1 + x)m−n in two possible ways. 1.5 Recurrences
P
Theorem 2. Suppose we know that k ak xk = Φ(x) = Q(x) , for two poly( x)
nomials P (x) and Q(x). This implies that Q(x)Φ(x) = P (x). Then, by
making the coeﬃcient of xi in Q(x)Φ(x) be equal to the one in P (x), we can
ﬁnd a linear recurrence for the ak , as well as the initial conditions.
Example 3. (To be) discussed at review session. 1.6 Solving problems using generating functions We will solve now diﬀerent problems concerning combinatorial objects, using
generating functions. The general idea is always the same.
• We identify the underlying set of conﬁgurations.
• We assign them a weight function.
• Using the information obtained in the previous steps, we calculate the
generating function.
1.6.1 Partitions of an integer Theorem 3. The number of solutions to t1 + . . . + tk = n, with n, k, ti all
k
≥ 0, is equal to n+n−1 . Remark 5. The previous theorem is proved in the course notes using generating functions. However, there is a simple combinatorial solution. Consider a sequence of n + k − 1 cells of length 1 in a line. Then, a choice of
k − 1 cells will delimit k possibly empty ranges for which the sum of their
lengths is n. Every set of such ranges is uniquely determined by a choice of
k − 1 delimiters.
n+k−1 n+k−1 Therefore, the number of solutions to t1 + . . . + tk = n is
=
.
k −1
n Remark 6. The proof in the previous remark can be adapted to show that
the number of ways to pick k elements from a larger set of n elements,
allowing for repetition, and not caring about the order, is equal also to
n + k − 1
k −1 .
Theorem 4. The number of solutions to t1 + . . . + tk = n, with n, k, ti all
− 1
≥ 1, is equal to n−1 .
k Deﬁnition 4. A composition of n with k parts is an ordered list of positive
integers c1 , . . . , ck such that c1 + . . . + ck = n. If n ≥ 1, note that k ≥ 1. If
n = 0, we allow a single composition of 0, with 0 parts.
Remark 7. Theorem 4 is equivalent to saying that the number of compo − 1
sitions of n with k parts is n−1 .
k Example 4 (Problem Set 2.2, Exercise 4). A travel agency has pamphlets
of 6 diﬀerent kinds. We can take at most 7 pamphlets, and at most 2
pamphlets of each kind We want to know how many choices can we make.
Each conﬁguration is a selection of pamphlets. If the weight of a sequence
of pamphlets is the number of pamphlets, the generating function for all
possible choices of pamphlets picking at most two of any one kind is equal
to
(1 + x + x2 )6
Using the Binomial Theorem, we expand this as
6
6
i=0 i 2i (x + x ) = i
6 i i=0 xi (1 + x)i . Using the Binomial Theorem again, we obtain
6
6
i=0 i x i i
i
j =0 j xj . Grouping together terms with the same sum of i + j , we obtain
6
ik
x.
i
j
i+j =k,j ≤i≤6 The number of choices in which we pick at most 7 pamphlets is then
equal to the sum of the coeﬃcients of xk , for 0 ≤ k ≤ 7.
This is equal then to
60
61
62
61
63
62
64
63
62
+
+
+
+
+
+
+
+
00
10
20
11
30
21
40
31
22
65
64
63
66
65
64
63
+
+
+
+
+
+
+
.
50
41
32
60
51
42
33
This is equal to
1 + 6 + 15 + 6 + 20 + 30 + 15 + 60 + 15 + 6 + 60 + 60 + 1 + 30 + 90 + 20 = 435.
Example 5 (Problem Set 2.2, Exercise 11). (To be) discussed at review
session.
1.6.2 Binary strings Deﬁnition 5. We will ﬁrst remember some notation:
• There is a single binary string of length 0, called the empty string.
• Let A and B be sets of binary strings. Then, AB = {ab s.t. a belongs
to A, b belongs to B }.
• Let A be a set of binary strings. Then, A∗ = ∪ A ∪ AA ∪ AAA ∪ . . .
Theorem 5. Let A and B be sets of binary strings. If the elements of AB
are uniquely created, then ΦAB (x) = ΦA (x)ΦB (x). If the elements of A∗ are
uniquely created, then ΦA∗ (x) = (1 − ΦA (x))−1 .
The following formulas generate all binary strings uniquely:
• {1}∗ ({0}{1}∗ )∗
• {0}∗ ({1}{0}∗ )∗
• {1}∗ ({0}{0}∗ {1}{1}∗ )∗ {0}∗
• {0}∗ ({1}{1}∗ {0}{0}∗ )∗ {1}∗
Example 6 (Includes parts (a), (c) and (f) of Problem Set 2.5, Question 3).
We can start from the previous formulas to create formulas that generate
uniquely sets of binary strings: • The binary strings that have no substrings of 0s with length 3:
We modify the second of the four decompositions, and obtain
{, 0, 00} ({1}{, 0, 00})∗ . • The binary strings that have no blocks of 1s with length 3:
We modify the ﬁrst of the four decompositions, and obtain
({, 1, 11} ∪ 1111{1}∗ ) ({0} ({, 1, 11} ∪ 1111{1}∗ ))∗ . • Part (a) of Problem Set 2.5, Question 3. The binary strings that have
no substring of 0s with length 3, and no substring of 1s with length 2:
We modify the fourth of the four decompositions, and obtain
{, 0, 00} ({1}{0, 00})∗ {, 1}.
• Part (c) of Problem Set 2.5, Question 3. The binary strings in which
011 does not occur as a substring:
We modify the ﬁrst of the four decompositions, and obtain {1}∗ ({0}{, 1})∗ .
• Part (f) of Problem Set 2.5, Question 3. The binary strings in which
each oddlength block of 0s is followed by a nonempty block of 1s,
and each evenlength block of 0s is followed by an oddlength block of
1s:
We modify the third of the four decompositions, and obtain
{1}∗ (({0}{00}∗ {11}{11}∗ ) ∪ ({00}{00}∗ {1}{11}∗ ))∗ .
The previous decompositions all generate strings uniquely. It follows
from them being restrictions of unique decompositions of the set of all binary
strings.
1.6.3 Recursion Sometimes, we characterize the set of conﬁgurations recursively. That gives
us then a functional equation where our variable is the generating function.
Example 7 (Problem Set 2.5, Question 14a). Let A be the set of strings in
which every block of 0’s is followed by a block of 1’s of the same length. We
can decompose A uniquely into {1}∗ B , where B is the empty string, plus
the set of strings in which the initial block is a block of 0’s, and every block
of 0’s is followed by a block of 1’s of the same length.
Therefore,
1
ΦA ( x ) =
ΦB ( x ) .
1−x Now, we can also uniquely decompose B as ∪ {01, 0011, 000111, . . .}B .
Therefore,
2 4 6 ΦB ( x ) = 1 + ( x + x + x + . . . ) ΦB ( x ) = 1 +
1
− 1 ΦB ( x ) .
1 − x2 We obtain then
1 − x2
ΦB (x) 2(1 − x2 ) − 1 = 1 − x2 ⇐⇒ ΦB (x) =
.
1 − 2x 2
Therefore,
ΦA ( x ) = 1 (1 + x)(1 − x)
1+x
=
.
1−x
1 − 2x 2
1 − 2x2 Remark 8. If in the previous solution we said “Now, we can also uniquely
decompose B as {, 01, 0011, 000111, . . .}B .”, we would be making a mistake.
Why?
1.6.4 Binary trees Deﬁnition 6. A binary tree is a tree with a ﬁxed root node; each node has
a left branch and a right branch (either of which might be empty). We allow
for an empty binary tree, denoted by .
n
1
Theorem 6. The number of binary trees with n edges is n+1 2n , the nth
Catalan number.
1.6.5 Bivariate generating functions Theorem 7. A bivariate weight function assigns two diﬀerent weights w1 (s)
and w2 (s) to each conﬁguration s. The corresponding generating function is
then F (x, y ) = s xw1 (s) y w2 (s) . This can be extended to three weights, with
a third variable z , and so on.
Remark 9. F (x, 1) is the generating function for only the ﬁrst weight.
Similarly, F (1, y ) is the generating function for only the second weight.
Theorem 8. The average value of the second weight over all conﬁgurations
with ﬁrst weight n is given by
[xn ] ∂ F (x, 1)
∂y
[xn ]F (x, 1) . Remark 10. Note that this is diﬀerent from saying that the average value
of the second weight over all conﬁgurations with ﬁrst weight n is given by
∂F
(x, 1)
n ∂y [x ] F (x, 1) . This appears in your course notes in the particular case in which our
conﬁgurations are binary strings, the ﬁrst weight is the length, and the
second weight is the number of occurrence of some property P :
Theorem 9. Let R be a set of binary strings, and cn,k be the number of
strings in R of length n with k occurrences of property P , n, k ≥ 0. Let the
corresponding bivariate generating function (with weights the length and the
number of occurrences of P ) be
F (x, y ) = cn,k xn y k . n ≥0 k ≥0 Then, the average number of occurrences of property P among the binary
strings in R of length n is
[xn ] ∂ F (x, 1)
∂y
[xn ]F (x, 1) . Example 8 (Problem Set 2.6, Exercise 2). (To be) discussed at review
session. 1.7 Homogeneous recurrence relations Deﬁnition 7. The characteristic polynomial of the recurrence cn + q1 cn−1 +
. . . + qk cn−k = 0 is the polynomial xk + q1 xk−1 + . . . + qk−1 x + qk .
Theorem 10. If the characteristic polynomial of this recurrence has roots
β1 , . . . , βj with multiplicities m1 , . . . , mj , for i = 1, . . . , j , then the unique
solution to the recurrence is given by
n
n
cn = P1 (n)β1 + . . . + Pj (n)βj , where Pi (n) is a polynomial in n with degree less than mi , and the Pi are
determined by the initial conditions.
Remark 11. Note that if all the roots are unique, all the Pi are just constants. Remark 12. Note that we can then also go back from the general solution
to the characteristic polynomial.
Example 9. Suppose we want to ﬁnd a linear recurrence relation that
satisﬁes cn = n2 + n. We can write n2 + n as (n2 + n)1n + 0 ∗ 1n + 0 ∗
1n . Therefore, a characteristic polynomial that produces this recurrence is
(x − 1)3 = x3 − 3x2 + 3x − 1, and a linear recurrence equation for cn is
cn − 3cn−1 + 3cn−2 − cn−3 = 0. Initial conditions are obtained from the
formula for cn , which gives c0 = 0, c1 = 2, c2 = 6.
Remark 13. If in the solution to the previous example we said “We can
write n2 + n as (n2 + n)1n + 0 ∗ 2n + 0 ∗ 3n . Therefore, a characteristic
polynomial that produces this recurrence is (x − 1)(x − 2)(x − 3)”, we would
be making a mistake. Why?
Example 10 (Problem Set 3.1, Exercise 1). (To be) discussed at review
session. 2 Introduction to Graph Theory Deﬁnition 8. A graph G is a set V (G) of nodes (also called vertices), and a
set E (G) of edges. Every edge is an unordered pair of two distinct elements
of V .
Deﬁnition 9. The degree deg (v ) of a node v is the number of edges connecting it to another node.
Theorem 11. For a graph G having q edges, we have
deg (v ) = 2q. v ∈ V (g ) Corollary 1 (The Handshake Theorem). The number of vertices of odd
degree in a graph is even.
Deﬁnition 10. A subgraph of a graph G is a graph whose nodes are a subset
of V (G), and its edges are a subset of E (G).
Deﬁnition 11. A graph is bipartite if its nodes can be partitioned into two
sets A and B such that all edges join a node in A and a node in B . Remark 14. Note that if a graph contains a triangle as a subgraph, it
cannot be bipartite, since no matter how we distribute the nodes of the
triangle into A and B , there will be two nodes in the same set connected to
each other. This can be generalized to any cycle of odd length (a cycle will
be deﬁned formally later). And indeed, as you will see later in the course, a
graph is bipartite if and only if it contains no cycle of odd length.
Example 11 (5a), Fall 2008 Final Exam). We want to prove that if G is a
bipartite graph, and each vertex of G has degree at least 3, then G contains
a path of length at least 5.
To do this, ﬁrst consider v , an arbitrary node of G. This node has
degree at least 3, so it is connected by an edge to at least two other nodes
w and x. w cannot be connected to a neighbour of v , since then we would
have a triangle. It is then connected to two nodes y and z that are not
neighbours of v . The same reasoning applied to x gives us two nodes y
and z that neighbour x and are not neighbours of v . Either y is not equal
to y , or y is not equal to z . In the ﬁrst case we have a path of length 5
y → x → v → w → y . In the second one we have y → x → v → w → z . 2.1 Families of graphs Deﬁnition 12 (complete graph). The complete graph Kn on n nodes is the
one in which all distinct pairs of nodes are connected by an edge.
Deﬁnition 13 (complete bipartite graph). The complete bipartite graph
Kn,m has a set A of n nodes all adjacent to all the nodes in a set B of m
vertices. There are no edges between nodes in A or nodes in B .
Deﬁnition 14 (cube graph). The ncube is the graph whose nodes are the
{0, 1} strings of length n, and two strings are adjacent if they diﬀer in exactly
one position.
Remark 15. If two nodes are connected by an edge in the a graph, the
parity (whether the number of 1’s is even or odd) of the corresponding
strings diﬀer. Therefore, cube graphs are bipartite. 2.2 Graph isomorphism Deﬁnition 15. Two graphs G1 and G2 are isomorphic if we can rename
the nodes of G1 and obtain G2 that way. Remark 16. To prove that two graphs are isomorphic, we give an appropriate renaming. To prove that two graphs are not isomorphic, we come up
with a property that is invariant under renamings, and true in one of G1
and G2 but not the other.
Example 12 (Question 6, Winter 2009 Final Exam). We rename A as 5, B as 6, C as 2, D as 1, E as 8, F as 7, G as 3, and
H as 4.
To come up with this renaming, ﬁrst we observe that B, C, F, G looks
similar to 2, 3, 6, 7, with C and G corresponding to 2 and 3, and B and F
corresponding to 6 and 7. Then, if we try to extend this renaming, A has
to correspond to 1, since A is the only neighbour of B in the ﬁrst graph not
in B, C, F, G , and 1 is the only neighbour of 2 in the second graph not in
2, 3, 6, 7. The same reasoning for D, E and H completes the renaming. The ﬁrst test that we can use to conﬁrm that the two graphs are not
isomorphic is whether for each degree d, the number of nodes with degree
equal to d is the same in both graphs. If this was not the case, then we
would be able to establish that the graphs are not isomorphic. However,
it is actually the case that in both graphs there are 2 nodes of degree 1, 2
nodes of degree 4, and 6 nodes of degree 3.
We can also test whether there exist degrees d1 and d2 such that the
number of nodes of degree d1 connected by an edge to at least a node of
degree d2 diﬀers from one graph to the other. However, in this case that test will also not be able to determine that the two graphs are not isomorphic.
A test that allows us to determine that the two graphs are not isomorphic
is whether there exist degrees d1 and d2 and a length l, such that the number
of paths of length l from a node of degree d1 to a node of degree d2 diﬀers
from one graph to the other. Indeed, in the leftmost graph there is only one
path of length 4 between the two nodes of degree 1 (K − D − A − B − J ),
and in the rightmost graph there are two such paths (10 − 4 − 1 − 2 − 9 and
10 − 4 − 3 − 2 − 9). 2.3 Adjacency and incidence matrices Deﬁnition 16. The adjacency matrix of a graph V with n nodes {v1 , . . . , vn }
is an n by n matrix A, with ai,j equal to 1 whenever vi and vj are connected,
and equal to 0 otherwise.
Remark 17. The adjacency matrix is symmetric and has all zeros in its
diagonal.
Deﬁnition 17. The incidence matrix of a graph V with n nodes {v1 , . . . , vn }
and q edges {e1 , . . . , eq } is an n by q matrix B , with ai,j equal to 1 whenever
vi is an endpoint of ej , and equal to 0 otherwise.
Remark 18. The nondiagonal entries of BB t are equal to the entry of A
in the same position. The diagonal entry in row i is equal to the degree of
node vi . 2.4 Paths and cycles Deﬁnition 18. A walk is an alternating sequence of nodes and edges of G,
beginning and ending in a node.
Deﬁnition 19. The length of a walk is the number of edges in it.
Deﬁnition 20. A path is a walk in which all the nodes are distinct. This
implies all the edges are distinct.
Theorem 12. If there is a walk from node x to node y , there is a path from
x to y .
Corollary 2. If there is a path from x to y , and a path from y to z , there
is a path from x to z .
Deﬁnition 21. A walk is closed if the ﬁrst node is the same as the last one. Deﬁnition 22. A cycle is a closed walk with no repeated nodes except the
ﬁrst and the last one.
Deﬁnition 23. A Hamilton cycle is a cycle that visits every vertex in the
graph
Example 13 (Problem set 4.3, 7). (To be) discussed at review session. 2.5 Connectivity Deﬁnition 24. A graph is connected if for any two nodes x and y , there is
a path from x to y .
Deﬁnition 25. A component of a graph is a maximal connected subgraph
of G (i.e. a subgraph that cannot include any extra nodes or edges without
becoming disconnected).
Remark 19. A graph is connected iﬀ it has exactly 1 component.
Theorem 13. A graph is connected iﬀ for some ﬁxed node v , there is a path
to any other node.
Deﬁnition 26. Given a subset of the nodes of a graph, the cut induced by
the subset is the set of edges that have exactly one endpoint in it.
Theorem 14. A graph is not connected iﬀ there is a proper nonempty subset
of its nodes such that the cut induced by them is empty.
Deﬁnition 27. An edge e of a graph G is called a bridge if when we remove
it, the component of the graph to which it belongs is not connected anymore.
Remark 20. This is equivalent to deﬁning bridges as edges whose deletion
increases the number of connected components of the graph.
Lemma 3. If an edge (x, y ) is a bridge of a connected graph, then after
deleting the edge we obtain a graph with precisely two components. Furthermore, x and y are in two diﬀerent components.
Theorem 15. An edge is a bridge if and only if it is not contained in any
cycle.
Corollary 3. If there are two distinct paths in a graph between a pair of
nodes, then there is a cycle in the graph. Example 14. We will prove that a graph on n nodes, n ≥ 2, is connected
if and only if A + A2 + . . . + An−1 does not have any zero entry outside its
diagonal, where A is the adjacency matrix of the graph.
First, we observe that the (i, j )th entry of Ak is the number of walks of
length k from vi to vj in the graph. This can be proved by induction, and
is question 2a) in Problem Set 4.3. Note that it implies that all the entries
of Ak are nonnegative.
Now, we observe that the maximum distance of a path between two
diﬀerent nodes is n − 1, since otherwise there are repeated nodes. This means
that two nodes are connected by a path if and only if they are connected by
a path of length k , for some k between 1 and n − 1.
If a two nodes are connected by a path of length k , then they are connected by a walk of length k , as paths are walk. And also, if two nodes are
connected by a path of walk k , then they are connected by a path of length
≤ k , using Theorem 4.3.2 and its proof. Therefore, two nodes are connected
by a path if and only if they are connected by a walk of length k , for some
k between 1 and n − 1.
By our previous observation, this is equivalent to saying that two nodes
are connected by a path if and only if the (i, j )th entry of Ak is not zero
for some k . As the entries of the Ak are all nonnegative, we have that two
nodes vi and vj are connected by a path if and only if the (i, j )th entry of
A1 + . . . + An−1 is not zero.
As a graph if connected whenever all distinct pairs of nodes are connected, we obtain then that a graph is connected if and only all nondiagonal
entries of (i, j )th entry of A1 + . . . + An−1 are not zero.
Example 15. There are no bridges in a 4regular graph. This follows from
the Handshake Theorem. Discussed in more detail in the review session. 3 Recommended exercises from the problem sets 4 Cheat sheet 1+… + n = ! n ( n + 1)
!!
2 ! " n % n ( n ( 1)
!
$ '=
2
# 2&
" a% a( a ( 1)… ( a ( k + 1)
!
$ '=
k ( k ( 1)…1
#k& ! ! 1 + 2 2 + 32 … + n 2 = n ( n + 1)(2 n + 1) !
6 ! ! ! !
! ! ! ! ! # "n&
k # n + k " 1&
% ( = ( "1) %
(!
$k'
$ n "1 '
" a% ! a
(1 + x ) = )$ 'x k !
k
k( 0 #& ! ! ! "#$%!&'%(!)*+,&'!$,.&$/%!(#/!)*&&*0$12!(0*!)*+,&'%3! (1 " x ) "1 = 1 + x + x 2 + ! ! ! (1 " 2 x ) "1 = 1 + 2 x + 4 x 2 + 8 x 3 + ! ! ! ! !
!
! ! 5 Tips for the midterm
• Move on to a diﬀerent question if you get stuck. As a rule of thumb,
you should not spend many more minutes on a question that the fraction of the total exam time corresponding to the percentage of points
of that question over the whole exam.
• If time allows it, do sanity checks. That is to say, conﬁrm that what
you obtain in your calculations is consistent with what we may call
common sense. For example, suppose that we want to compute the
generating function for the number of binary strings that have a certain
property. As there are only two binary strings of length 1, if you got
−1 or 3 as the coeﬃcient of the corresponding term, that means there
is a mistake somewhere in the calculation.
• A place where it is easy to make mistakes is in the indices of sums.
A good way to check that they are given correct values is to consider
the terms corresponding to the extremal cases (i.e. all indices take
their smallest/largest value), and run a sanity check for the values we
obtain.
• Do not forget you can add and subtract or multiply and divide to
transform an expression into a nicer equivalent one. For example,
1+ x + tx2 + x3 + . . . is not easy to express compactly, but if we add and
subtract x2 , we have that it is equal to 1+ x + x2 + x3 + . . . − x2 + tx2 =
1
2
2
1−x − x + tx . MATH 239 MIDTERM Introduction Outreach Trips •
•
•
• Cusco, Peru
Aug/20/2010Sept/4/2010
22 volunteers
Built kindergarten, sewing
workshop, English
classroom
• NGO → Awaiting Angels
• Excursion: Machu Picchu
• Cost per person → $1900 •
•
•
• Colomba, Guatemala
Apr/23/2011May/6/2011
12 volunteers
Built classroom, latrine,
vegetable garden; installed
solar panel
• NGO → Reto Juvenil
• Excursion: Lake Atitlán,
Volcán San Pedro, etc.
• Cost per person → $1560 •
•
•
• Casa Hogar, Mexico
Aug/21/2011Sept/4/2011
14 volunteers
Finish youth skills training
building, set greenhouse
project for orphanage
• NGO → Reto Juvenil
• Excursion: TBA
• Cost per person → $1620 Join SOS and stay tuned for our next outreach trip! Backpack Challenge! • Full Impact of our classroom
building won’t be felt until the
children have sufficient school
supplies!
• Make direct impact by bringing
school stationery, old or new, to
the next ExamAID session! We
will take them to our outreach
trips!
• Feel free to personalize your item
& leave your mark! Enumeration
• How many blah are there with some
property?
– How many lineups can we have for a sports team?
– How many products in a given grocery store cost
less than 1 dollar per kilogram, and are not red
– How many white positions are there in a chess
board? Enumeration
• In a set of configurations, each of them with
an associated weight, how many
configurations are there of a particular
weight? Generating functions
• A way of writing down the answer to a counting problem
• If we have a set S of configurations and a weight function w,
the generating function S ( x) is x w( s)
sS k • This is the same as ak x , where ak is the number of
k0
configurations of weight k
• Example:
– The configurations are the numbers from 1 to 10. The weight is the
number modulo 4. Formal power series
• Infinite sum ai x i
i • As we said, this is just a way of encoding a1, a2, …
• We can sum and multiply them, as well as take derivatives:
ai x i bi x i i i ai x i ( ai bi ) x i
i bi x i i i x ( ai bi ) x i
i ai x i
i0 (i 1)ai 1 x i
i0 Formal power series
• If A(x) and B(x) are formal power series and B(x) has no
constant term, A(B(x)) is a formal power series • B(x) is the inverse of A(x) iff B(x)A(x)=1 • A formal power series has a inverse if and only if it has a nonzero constant term, and this inverse is unique Properties of generating
functions
• The sum of all coefficients is the number of configurations • The sum of the coefficients of the derivative is the sum of all
weights • If we divide these two quantities, we get the average weight Properties of generating
functions
• The Sum Lemma
– A and B are two disjoint sets of configurations, with generating functions
– The generating function for A U B is AB ( x) A ( x) B A and ( x) – More generally, for any A and B not necessarily disjoint, AB ( x) A ( x) B ( x) – This can be extended to more than one set • The Product Lemma
– If the weight of a pair (a,b) is the sum of their weights, the generating
function for A B is A B ( x) A ( x) B ( x)
– This can be extended to more than one set ( x) AB ( x) B ( x) Generalized binomial
coefficients
• Let a be any real number and k a nonnegative integer. Then
a
k a( a 1)K ( a k 1)
k (k 1)K 1 • If a is a nonnegative integer n, this is the number of subsets
of size k for a set of size n
• If a is a negative integer –n, this is
n
nk1
k
( 1)
k
n1 The binomial theorem
• For any rational number a, 1x a a
k0 (this generalizes 1 x n n k0 n
k k xk xk ) • From here it follows that:
1x nk1 n xk 1x 1
2 1 n1
note that the first formula is equivalent to
k0 1x nk1 n
k0 n1 ( x)k k ( 1) k 1 2k 2 k
x
2k 1
2 kk1
1 Calculating terms of a
generating function
• Final for Spring 2009, question 1a) Recurrences for the coefficients
of a generating function
• If ( x ) P ( x ) , we can use Q( x) ( x)
Q( x )
coefficients. P( x ) to solve for the Compositions of an integer
• We want to split a positive integer into several positive parts
• Example: Problem Set 2.2, Exercise 11. How many kpart
compositions of are there in which the ith part is at least i2? Binary strings
• Strings containing 0s and 1s • Notation:
– Standard set theory
– is the empty string
– If A and B are two sets of strings, AB is {aba is in A, b is in B}
– A*= U A U AA U AAA U AAAA U … Binary strings
• Let A and B be sets of binary strings
• If the elements of AB are uniquely created, then
AB ( x) A ( x) B ( x) • If the elements of A* are uniquely created, then
A* ( x) 1
1 A (x) Binary strings
• {1}*({0}{1}*)*
• {0}*({1}{0}*)*
• {1}*({0}{0}*{1}{1}*)*{0}* • {0}*({1}{1}*{0}{0}*)*{1}*
• Example 3d), 5a) Recursion
• The set of configurations is characterized recursively
– Binary trees
– Binary strings that avoid a certain substring
– Example: Strings that avoid 11011 Binary trees • The number of binary trees with n edges/n+1 nodes is
2n 1 n1n
• the nth Catalan number Bivariate problems
• In a bivariate weight function, each configuration has two weights. The
corresponding generating function is
F ( x, y ) c n ,k x n y k
n ,k 0 where cn,k is the number of configurations with weights n and k
• F(x,1) is the generating function if we only care about the first weight
• Similarly, F(1,y) is the generating function if we only care about the second
weight
• The average value of the second weight over all configurations with first
weight n is given by
F
xn
( x,1)
y
x n F ( x,1) Solving recurrence equations
• Homogeneous equations
cn q1cn 1 c0,c1,K ,ck K
1 qkcn k 0, n k are given • Such an equation has the associated characteristic polynomial
x k q1 x k 1 K qk 0 Solving recurrence equations
• To solve a homogeneous recurrence equation
– Find the roots 1 ,K , j of the characteristic polynomial • Useful tip: For integer roots in a polynomial with integer coefficients, they will
divide the last term of the polynomial – The solution will be of the form
n
P1( n) 1n P2 ( n) 2 K Pk ( n) n
j where Pi(n) is a polynomial in n with degree less than mi
– Use the initial conditions to determine the Pi(n) – Example. Problem set 3.1,1 Intro to graph theory
• What is a graph?
– Set V of nodes
– Set E of pairs of nodes (edges)
– Example: Intro to graph theory
• Pairs are unordered, they cannot be repeated,
and there cannot be loops.
• If two nodes are connected by an edge, they
are neighbors of each other.
– The number of neighbors of a node is called its
degree. Handshake Theorem
• The sum of the degrees is twice the number of edges • Corollary (Handshake Theorem): The number of odd degree
vertices in a graph is even Subgraphs and bipartite graphs
• A subgraph is what we obtain by considering a subset of the
nodes of a graph, and a subset of the edges (all of them
joining two of the nodes considered) • A graph is bipartite if we can split the nodes in two sets A and
B, with all edges between nodes in different sets Families of graphs
• Families of graphs
– Complete graph: n nodes all connected to each
other. – Cube graph: all binary strings of length n, two
strings connected if they differ in exactly one
position Intro to graph theory
• Isomorphism
– Two graphs are isomorphic when we can rename
the nodes to make them equal to each other.
– To prove two graphs are isomorphic, we give a
corresponding renaming.
– To prove two graphs are not isomorphic we give
something that distinguishes them. Adjacency and
incidence matrices
• Adjacency matrix: n x n matrix A, aij is:
– 1 if vi is adjacent to vj
– 0 otherwise • Incidence matrix: n x q matrix B, bij is:
– 1 if vi is and endpoint of to ej
– 0 otherwise Paths and cycles
•
•
•
•
• Walks
Paths
Cycles
Hamilton cycle.
If there is a walk from x to y, there is a path
from x to y
• If there is a path from x to y and a path from y
to z, there is a path from x to z
• Problem set 4.3, 7 Connectivity
• Connectedness
– A graph is connected if we can go from any node
to any other node
– It is enough that there is a node from which we
can go to all other ones
– Components Connectivity
• The cut defined by a set of nodes is the set of edges
going from them to the rest of the graph
• A graph is not connected iff there is an empty cut
• Bridges are edges that make things that were
connected, not connected anymore Connectivity
• Deleting a bridge turns a component into exactly two,
with the two endpoints in the bridge in different ones • An edge if a bridge if and only if it is not contained in any
cycle
• If there are two distinct paths between a pair of nodes,
then there is a cycle
• Example: There are no bridges in a 4regular graph ...
View
Full
Document
This note was uploaded on 08/13/2011 for the course MATH 239 taught by Professor M.pei during the Spring '09 term at Waterloo.
 Spring '09
 M.PEI
 Math

Click to edit the document details