Download as pdf or txt
Download as pdf or txt
You are on page 1of 12

CIS 160 - Spring 2016

(instructor Val Tannen)

Final Exam Review


Posted Friday, April 29
On Friday May 6 we will have our final exam from 9AM to 11AM The exam will take place in two rooms
MEYH B1 and MEYH B3. All the students whose last name begins with the letters:
A-H (inclusive) please come to MEYH B1;
I-N (inclusive) please come to MEYH B3;
O-Z (inclusive) please come also to MEYH B1.
The exam will last for 120 minutes. Please be in MEYH B1 and MEYH B3 at 8:50 so we have time to
seat everybody properly.
This here is a final exam review document with readings, a mock (practice) exam, and more problems.
You should solve this practice exam while timing yourselves.
Solutions to the practice exam will be posted early next week.
Val will hold a review session Wednesday May 4, 6-8PM in Towne 100 (Heilmeier Hall).
The TAs will hold a review session Thursday May 5, 6-9PM in Levine 101 (Wu&Chen Auditorium).

Readings and self-tests

STUDY IN-DEPTH... ... the posted outlines for lectures 1R-14TR. The material on number theory
covered on Tuesday April 26 is not required for the final exam.
STUDY IN-DEPTH... ...the posted solutions to homeworks 1-10. (Solutions to hw10 will be posted
very soon.) Compare with your own solutions.
STUDY IN-DEPTH... ...the problems with solutions in the review documents for midterms 1 and 2 as
well as the posted solutions to the midterm 1 and 2 problems.
STUDY IN-DEPTH... ...the solutions to the mock exam and the additional problems contained in this
handout, when they are posted Monday. Until then, try very hard to solve these on your own.
SUPPLEMENTARY READINGS AND PROBLEMS From Scheinerman, read Sections 1-13, 1522, (24, but see warning in Lecture 4R), 25, 26. Chapter 6, and Sections 47-52.
Also do the SELF-TESTS for Chapters Chapters 1, 2, 3, 4, 5 (1-16 only), 6, 9 (1-20 only). For the
self-tests, I recommend that you write down your solutions and only afterwards compare with the
solutions at the end of the book.

Memorize!

Find and memorize formulas:


For the sum of a geometric progression.
For the sum of the integers in [1..n].
For the sum of the squares of the integers in [1..n].
For the expectation and the variance of the Bernoulli, binomial, and geometric distributions.
For the Markov and Chebyshev inequalities.

Mock Exam (120 minutes for 240 points)


1. (50 pts) For each statement below, decide whether it is TRUE or FALSE and circle the right one. In
each case attach a very brief explanation of your answer.
(a) Let A, B be two finite nonempty sets. Then A B has exactly the same number of elements as
(A \ B) (B \ A), true or false?
(b) If |A| = n then there are n! injective functions with domain A and codomain A, true or false?
(c) Let P (n) be a predicate defined on natural numbers. The negation of the statement k P (k)
P (k + 1) is the statement k (P (k)) (P (k + 1)), true or false?
(d) We toss 3 fair coins C1 , C2 , C3 independently of each other. Then the event (C1 = C2 ) is
independent of the event (C2 = C3 ), true or false?
(e) A digraph in which all vertices have outdegree 1 is strongly connected, true or false?
(f) Let n 2. The complete bipartite graph Kn,n has at least (n!)2 distinct subgraphs isomorphic
to C2n , true or false?
For the two parts below, use the following definition: for any digraph G = (V, E) without selfloops and without cycles of length 2 define an undirected graph Gu = (V, E u ) that has the same
vertices as G and moreover in Gu we have an edge vw whenever we have the edge vw or the
edge wv in G.
(g) If G is strongly connected then Gu is connected, true or false?
(h) If G is a DAG then Gu is acyclic, true or false?
(i) Let G be an undirected graph in which all vertices have degree 3. Then G has an even number
of vertices, true or false?
(j) Let (, P ) be a probability space with 2 or more outcomes and X : R a random variable
such that Val(X) = {1, 1}. If E(X) = 0 then P (X = 1) = 1/2, true or false?
2. (15pts) Consider the recurrence relation
an+1 = an + 3 (n 0)
Prove that n 4 an 2n .
2

and

a0 = 4

3. (20pts) For each of the questions below give the answer and an explanation of how you derived it.
(a) Let n be an even natural number. Count the number of distinct sequences of bits of length n
in which the number of 0s exactly equals the number of 1s.
(b) Let n 2 be a natural number. Count the number of distinct sequences of bits of length n with
exactly two 1s.
(c) Let n 5 be a natural number. Count the number of distinct sequences of bits of length n with
at least two 1s and
at least three 0s.
4. (35pts) Alice is playing Biased Coins with three distinct biased coins, C1 , C2 , and C3 . These coins
show heads with probability 1/3 and tails with probability 2/3. Alices game proceeds as follows.
Alice tosses coin C1 .
If C1 showed heads then Alice tosses coins C2 and C3 .
If C2 and C3 showed the same side (both are heads or both are tails) then Alice wins, otherwise
she loses.
However, if coin C1 showed tails then Alice tosses only coin C2 . Then, if coin C2 shows heads
Alice wins, otherwise she loses.
(a) Draw the tree of possibilities diagram that describes the sample space for this game, with all
outcomes and their probabilities. (Warning: in order to answer the questions below you will
need the outcomes to represent more than just win/lose.)
(b) Using the diagram, compute in this probability space the probability that Alice wins the game.
(c) Compute in this probability space the conditional probability P (E|F ) when E is Alice wins
and F is coin C2 shows heads.
(d) Show that in this probability space the events G1 denoting coin C1 shows tails and G2 denoting
coin C2 shows tails are independent, G1 G2 .
(e) Suppose Alice has already played her game. She doesnt tell you whether she won or not but
she challenges you to guess it. To help, she is willing to disclose to you one (but not both) of
the following two pieces of information:
What C1 showed when she played the game, OR
What C2 showed when she played the game.
Which of the two should you ask to see in order to make a better informed guess? Briefly explain
your answer.
5. (35pts) Let n 2 be a natural number. Consider the set W of nonempty subsets of [1..n]. By
the Well-Ordering Principle, each A W has a unique least element. Lets denote this element by
min(A). Define a binary relation on W as follows: for any A, B W
AB

iff

min(A) = min(B)

It is easy to see that is an equivalence relation on W (you dont have to prove this). In answering
the parts of this question make sure your answer works for any n 2.
(For each of the questions below give the answer and an explanation of how you derived it. No proofs
required.)
(a) Give an example of A, B W such that A 6= B but A B.
(b) Express in terms of n the number of distinct equivalence classes determined by .
(c) What is the size of the smallest equivalence class determined by ?
(d) Express in terms of n the size of a largest equivalence class determined by .
(e) Let A W . Express in terms of n and of k = min(A) the size of the equivalence class of A.
6. (15pts) Give a combinatorial proof of the identity
 

 

99
99
100
+
=
29
30
70

Specifically, you have to identify a counting problem such that counting one way you get 100
70 and


99
counting another way you get 99
+
.
You
are
not
allowed
to
rearrange
the
sides
of
the
identity
30
29
and you are not allowed to use any other identities about binomial coeffcients, or to express them in
terms of factorials.
7. (15pts) Let G be a bipartite graph in which every connected component is a cycle.
(a) Draw the smallest such G. (Just the drawing, no need for explanation)
(b) Prove that, not just in the smallest, but in any such G the number of red nodes is equal to the
number of blue nodes.
8. (30pts) Here is a list of facts about probability (X, Y are arbitrary events in some probability space
(, P ) and X = \ X):
(F1) P () = 0 and P () = 1
(F2) X Y = implies P (X Y ) = P (X) + P (Y )
(F3) P (X) = 1 P (X)
(F4) X Y implies P (X) P (Y )
(F5) P (X Y ) = P (X) + P (Y ) P (X Y )
(F6) P (X) = P (X | Y ) P (Y ) + P (X | Y ) P (Y )
(F7) P (X | Y ) = P (Y | X) P (X)/P (Y )

(law of total probability)

(Bayes law)

(a) Complete (replace the question mark with the correct formula) the definition of conditional
probability below:
P (X | Y ) = ?

(b) Complete (replace the question mark with one of the correct properties) the definition of event
independence below:
X Y if f ?
(c) Now let A, B be two events in a probability space (, P ) such that 0 < P (A) < 1 and
0 < P (B) < 1, i.e., neither P (A) nor P (B) can be 0 or 1. As usual, let A = \ A.
Denote p = P (A), as well as q = P (B) and r = P (A B).
Using only the facts about probability in the list (F1)-(F7) above (you must indicate when you
use them), compute P (A | B) in terms of p, q, r.
(You can also use set algebra identities that seem obvious to you, however you must state and
circle these identities and write we assume next to them.)
(d) With A, B as in part (8c), prove that A B implies A B.
(Again you can use only the facts about probability in the list (F1)-(F7) you must indicate
when you use them and you can also use set algebra identities that seem obvious to you,
however you must state and circle these identities and write we assume next to them.)
9. (10pts) Let n 1 be a natural number. Draw (use dot dot dot) an example of a DAG with exactly
3n + 1 vertices among which there is exactly one source s and exactly one sink t such that there are
exactly 3n distinct directed paths from s to t.
10. (10pts) Let G = (V, E) be a connected graph with at least two distinct spanning trees.
(a) Prove that |E| |V |.
(b) Prove that the graph has at least three distinct spanning trees.
11. (5pts) Find the minimum value for k that ensures that any graph in which every vertex has degree
k or more has at least one cycle of even length. Prove your answer.

Additional Problems
1. For each statement below, decide whether it is true or false. In each case attach a very brief explanation of your answer.
(a) If f : A B, where A is nonempty and |B| = 1, then f is surjective, true or false?
(b) Suppose that A, B, C are each finite nonempty sets, each with an even number of elements, and
that A and B are disjoint. Then |(A B) C| is divisible by 4, true or false?
(c) Suppose that A, B are finite nonempty sets such that A B has 4 elements. Then, |A \ B| =
|B \ A| = |A B| = 1, true or false?
(d) There exists an undirected acyclic graph with 5 vertices, 3 connected components, and 2 edges,
true or false?
(e) For any function f : N N the following holds: m n f (n) m, true or false?

(f) There exists a tree with exactly 3 leaves, in which the length of a longest path is 1000, true or
false?
(g) There exist DAGs in which all vertices have outdegree 2, true or false?
(h) In any DAG the reachability relationship, , has the property xy yx x = y (this is
called antisymmetry) , true or false?
2. Let (, P ) where P : [0, 1] be a probability space, A, B be two events, and A = \ A and
B = \ B be their complements. Here is a list of facts about probability:
(F1) P () = 0
(F2) P (X Y ) = P (X) + P (Y ) P (X Y )
(F2) P (X Y ) = P (X) + P (Y ) when X Y =
(F3) P (X) = 1 P (X)
Using only the facts about probability in the list above prove that if A B then A B.
(You can also use set algebra identities that seem obvious to you, however you must state and circle
these identities and write we assume next to them.)
3. Consider a connected graph G = (V, E) such that |E| = |V |. Prove that G contains exactly one cycle.
4. Consider a set A with n 1 elements. We color indepedently each of the elements of A red with
probability 1/3 and blue with probability 2/3. This determines a partition on A: in one block (the
blue block) we have all the blue elements and in the other block (the red block) we have all
the red elements. Let be the equivalence relation that corresponds to this partition. Calculate the
expected value of ||. No proof necessary but explain your calculation.
5. Let X = {1, 2, . . . , 2n} where n 2. How many nonempty subsets of X contain at most 2 odd
numbers?
6. Prove that in any DAG we have 2 |E| |V |(|V | 1). (Hint: use induction on the number of
vertices.)
7. Let X be a set with n 2 elements and A, B X two nonempty disjoint subsets of X. Denote
p = |A| and q = |B|. Consider the set
WA,B = {C 2X | A C or B C}
Compute |WA,B | in terms of n, p, q.
8. Prove by induction that n 4 n2 2n .
9. In a bizarre parallel universe they are able to manufacture fair n-dice for various n 1. Such a die
has n faces showing the numbers {1, 2, . . . , n}. Because the dice are fair, when you roll them, each
of these n numbers shows up with equal probability, 1/n. A citizen of this universe, Bizz, plays the
following game: it rolls independently two n-dice, a red one, and we denote by Red the number the
red die shows, and a blue one and we denote by Blue the number the blue die shows. If Red < Blue
6

then Bizz wins, otherwise it loses. For the following questions give the answer and a short explanation
of how you obtained it. No proofs required. (Hint: first think that n = 6 so these are normal dice,
then generalize.)
(a) How many outcomes does the prob. space associated with Bizzs game have? What is the
probability of each outcome?
(b) Compute the probability that Bizz wins. (Hint: for n = 6 this probability should be 5/12 so
you can check what you got.)
(c) Consider a random variable X defined on the probability space of Bizzs game representing Bizzz
monetary gains/losses: When Bizz wins, it receives $2, when it loses, it pays $1. Compute the
expectation of X. (Hint: for n = 6 this expectation should be 0.25 so you can check what you
got.)
(d) Let E be the event Bizz wins. Fix i such that 1 i n. Let Fi be the event Red = i,
Compute the conditional probability P (E|Fi ).
10. Let A be a nonempty set. A partition of A is a refinement of another partition of A when
every block of is the union of blocks of .
Let 1 , 2 be two partitions of A. prove that there exist a partition 3 of A that is a refinement of
both 1 and 2 and for any other partition 4 that is a refinement of both 1 and 2 we have that
pi4 is also a refinement of 3 .
11. Let A, B, C be three sets. Prove that if A B then C \ B C \ A.
12. Consider strings (sequences) over the 3-letter alphabet {a, b, c} and the set W of these strings such
that
the total number of as in the string is exactly m, where m 1;
the total number of bs in the string is exactly n, where n 1;
there are exactly 3 cs in the string.
For the following questions just give the answer. No explanation and no proofs required.
(a) Let L be the length of a string in W . Compute L in terms of m and n.
(b) In how many different ways can the cs be placed in a string of length L?
(c) In terms of m and n, how many different strings are there in W ?
13. Prove by ordinary induction that for any n N we have
n
X

22i =

i=0

22n+2 1
3

You must prove this by induction; you are not allowed to use the formula for the sum of a geometric
progression.
14. Recall that Km,n , m, n 1 is the complete bipartite undirected graph with m vertices colored (say)
red, and n vertices colored (say) blue and with edges between any red node and any blue node.
7

(a) Draw K3,2 . Name the red vertices r1 , r2 , r3 and the blue vertices b1 , b2 .
(b) Draw a spanning tree of K3,2 using the same vertex names as in part 14a.
(c) How many edges do we have to delete from Km,n so we are left with a spanning tree? Give the
answer in terms of m and n and a short explanation of how you obtained it. No proofs required.
(d) Assume that m, n 2. What is the biggest length that a cycle can have in Km,n ? Give the
answer in terms of m and n and a short explanation of how you obtained it. No proofs required.
15. Let f, g be two functions with domain N and codomain N. Define h : N N by n N h(n) =
g(f (n)). Consider the statement P : if h is injective then f is injective. Write down the contrapositive Pc of this statement then prove Pc .
16. Let A, B, C be three finite nonempty sets such that |A B C| = |A| + |B| + |C|. Prove that the
sets A, B, C must be pairwise disjoint, that is, A B = B C = C A = .
17. Recall the complete undirected graph on n vertices, Kn . Prove that for any n 4 it is possible to
assign direction to each of the edges of Kn such that the resulting digraph has exactly n 2 strongly
connected components.
18. Let X be a finite nonempty set. Consider the digraph G = (V, E) such that the vertices are all the
subsets of X, i.e., V = 2X and the edges are defined as follows. Given two vertices, A and B, there
is a directed edge from A to B iff B has all the elements of A plus some other element, i.e., there
exists some x X such that x 6 A and B = A {x}.
(a) Draw the digraph G for the case X = {1, 2, 3}.
(b) No doubt you noticed that the digraph you drew in part 18a is a DAG. Give a topological sort
for it.
(c) Now X is an arbitrary finite nonempty set. Prove by induction on directed walk length that if
there is a directed walk of length 1 from A to B in G then A B. (Here, A B stands for
strict subset, i.e., A B but A 6= B.)
(d) Now X is again an arbitrary finite nonempty set. Let n = |X|. What is the biggest length that
a directed path can have in G? Give the answer and a short explanation of how you obtained
it. No proofs required.
(e) Now X is again an arbitrary finite nonempty set. Prove that G is a DAG.
(f) Now X is again an arbitrary finite nonempty set. Again let n = |X|. Prove that G has n 2n1
edges. (Hint: you can prove this by induction on n or you can give a combinatorial proof.)
19. For each statement below, decide whether it is true or false. In each case attach a very brief explanation of your answer.
(a) Let f : N N and let the subset A N have 100 elements. Then the image imf must also
have 100 elements, true or false?
(b) The function f : N N f (x) = 2x 1 is a bijection, true or false?
(c) Let T be a complete ordered binary tree of height 100. If l is the number of leaves of T and d
is the number of nodes of T at depth 99 then l = 2 d, true or false?
8

(d) Let A, B be events in a finite probability space such that Pr[A] = 1/4 and Pr[A B] = 1/2.
Then, 1/4 Pr[B] 1/2, true or false?
(e) Consider a poset with an element m that is both maximal and minimal. Then, the poset has
exactly one element, namely m, true or false?
(f) There exists a directed graph with 3 vertices, 2 strongly connected components, and 1 edge,
true or false?
(g) Consider an undirected graph with 3 or more vertices and with exactly 3 connected components.
In order to make this into a connected graph we must add at least 2 edges, true or false?
(h) Let A, B be nonempty sets and let f : A B and g : B A be two functions such that g f
is a bijection. Then, |A| = |B|, true or false?
20. Let X be such that |X| = n 2 and let be an equivalence relation on X that has exactly one
equivalence class. Compute || in terms of n.
21. Let A, B, C be arbitrary finite sets. Prove that |A| + |B| + |C| |A B| + |B C| + |C A|.
22. Let A, B, C be finite sets. Prove that (A B) (B \ C) B
23. Weird Al (WAl) is playing with his coins. The game uses two fair coins and one urn. The result of
the game is one of H (heads) or T (tails) and is determined as follows:
WAl places both coins in the urn.
WAl reaches inside the urn and (a) with probability 2/3 WAl grabs one of the coins and tosses
it, OR (b) with probability 1/3 WAl grabs both coins, then tosses them separately in some order
(doesnt matter which order).
If WAl has tossed just one coin then whatever that coin shows is the result of the game. If WAl
has tossed both coins then applying the weird operation to what the two coins show is the
result of the game, where T T = T , T H = H, H T = H, and H H = T .
(a) Draw the tree of possibilities diagram for WAls game.
(b) Calculate the probability that the result of of the game is H.
(c) What simpler game could Weird Al play that would give him exactly the same odds?
24. Consider strings over the 2-letter alphabet {a, b} and the set W of these strings such that
each string starts with an a and end with two bs;
there are exactly m total number of as in the string (including the first one) where m 1;
there are exactly n total number of bs in the string (including the last two ) where n 2.
How many such strings are there (in other words, what is |W |)?
25. Let n 3 be a natural number. Consider the undirected graph G = (V, E) where V = {0, 1, 2, . . . , n}
and E = {{1, 2}, {2, 3}, . . . , {n 1, n}, {n, 1}} {{0, 1}, {0, 2}, . . . , {0, n}}. As usual we count cycles
and paths as distinct subgraphs.
9

(a) Draw this graph. Use dot dot dot or use n = 5 for the figure.
(b) Count the number of cycles of length 3 or more.
(c) Count the number of paths of exactly length 2.
26. Let X be a finite nonempty set and f : X X. Let x X arbitrary and consider the sequence
x, f (x), f (f (x)), . . . , f ( f (x) ), . . .
Prove that for any k 2 there must exist k distinct positions in this sequence in which the same
element of X occurs.
27. For each statement below, decide whether it is true or false. In each case attach a very brief explanation of your answer.
(a) G = (V, E) be a (finite) connected undirected graph. Then G can have at most |E| + 1 vertices,
true or false?
(b) Assume that B is a set with 7 elements and that A is a set with 15 elements. Then, for any
function f : A B there exist at least 3 distinct elements of A that are mapped by f to the
same element of B, true or false?
(c) Assume that A, B are finite nonempty sets and f : A B is a function such that there exist at
least 3 distinct elements of A that are mapped by f to the same element of B. Then |A| > 2|B|,
true or false?
(d) The number of sequences of bits such that three of the bits are 0, three of the bits are 1, and
are such that they start with a 1 and end with two 0s is 8, true or false?
(e) The composition (look it up!) g f of an injection f with a surjection g is always a bijection,
true or false?
(f) Let X be a set with m elements and Y be a set with n elements. For any m 2 and n 2
there are twice as many binary relations with domain X and codomain Y than functions with
domain X and codomain Y , true or false?
(g) Let X be a finite set with 6 or more elements, and let p be the number of subsets of X of size
2. Then p > 2|X|, true or false?
(h) Let A be a finite set and let be an equivalence relation on A such that x A y
A xy AND x 6= y. Let m be the number of equivalence classes of and assume that |A|
is odd. Then |A| 2m + 1, true or false?
(i) Let X be a set with m elements and Y be a set with n elements such that m > n. Then, there
exist at least n distinct surjective function with domain X and codomain Y , true or false?
28. Let f : R R R R defined by f (x, y) = (x + y, x y) and let g = f f . Prove that g is an
bijection.
29. Let X be a finite nonempty subset of N. Let |X| = n and assume that n 2. Let W = 2X {}.
Define a function q : W X such that for any A W q(A) is the maximum natural number in A.
(a) Prove that q is surjective.
10

(b) Prove that q injective 2n 1 n.


(c) Prove by ordinary induction on n that for all n 2, n + 1 < 2n .
(d) Prove that q is not injective.
30. Let X and A be sets such that =
6 A X and let f : X X be a function (warning: the domain
and the codomain are the same set). Recall the definition of the direct image of A through f :
f (A) = {y X|a A y = f (a)}
Now denote f (A) by B. B is another subset of X so now we can talk about the direct image f (B),
in fact we can write f (f (A)) instead of f (B). Prove that f (A) A f (f (A)) f (A).
31. Let X, Y, Z be three finite nonempty sets such that X Y = , Z Y = , X Z = and denote
|X| = m, |Y | = n, |Z| = p. Assume that m < n < p. Let also f : X Y and g : Y Z be two
functions. Consider the undirected graph G = (V, E) where V = X Y Z and
E = { {x, f (x)} | x X} { {y, g(y)} | y Y }
(a) What is |V | and what is |E| (in terms of m, n, p)?.
(b) What is the maximum number of nodes of degree 0 that G can have (in terms of m, n, p)?.
(c) What is the minimum number of nodes of degree 0 that G can have (in terms of m, n, p)?.
(d) What is the maximum length that a path in G can have?
(e) Prove that G is acyclic (that is, it has no cycles of length 1).
32. Sophie is playing the following game:
First she chooses with equal probability one of the numbers 0, 1, . . . , 4, call it a.
Then she chooses with equal probability one of the remaining numbers, call it b.
Then she adds a + b = c and c is the result of her game.
(a) What possible results can Sophies game have?
(b) Draw the tree of possibilities diagram for Sophies game.
(c) We denote with R(c) the event that the result of the game is c. What is the probability of R(2)?
(d) What is the probability of R(2) R(3)?
(e) What is the conditional probability Pr[R(2)|R(2) R(3)]?
(f) Find two events E, F in the probability space of Sophies game such that neither is empty,
neither equals the whole sample space and E F .
33. For any digraph G = (V, E) without self-loops we define an undirected graph Gu = (V, E u ) that has
the same vertices as G and moreover in Gu we have an edge uv whenever we have the edge uv or
the edge vu (or both) in G.
(a) Prove that if Gu is acyclic then G is a DAG. Then give a counterexample that shows that the
converse of this statement is false.
11

(b) Prove that if G is strongly connected then Gu is connected. Then give a counterexample that
shows that the converse of this statement is false.
(c) Prove that if G is a DAG in which every sink is reachable from every source then Gu is connected.
34. Prove that a connected undirected graph in which every node has degree 2 is a cycle. (Hint: use
induction on the number of vertices.)
35. An r-regular graph is a graph in which the degree of each vertex is exactly r. Derive a simple algebraic
relation between r,n and m where n is the number of vertices and m is the number of edges.
36. Let G be a graph with n vertices and exactly n 1 edges. Prove that G has either a vertex of degree
1 or an isolated vertex.

12

You might also like