Docsity

CS 173: Discrete Structures - Final Review Problems - Prof. Margaret M. Fleck, Study notes of Discrete Structures and Graph Theory

Toggle sidebar
bg1
CS 173: Discrete Structures, Spring 2012
Final Review Problems
These problems should not be turned in. They are to help you review for the final.
1. Counting problems
(a) Let M={a, b, c, d}. How many different partitions of Mare there?
(b) In the game Tic-tac-toe (played on the usual 3 by 3 grid), how many different board
configurations are possible after four moves (i.e. two moves by each player)?
(c) Suppose we have a state diagram with nstates and kdifferent actions. In how many
different ways could we construct a transition function for this diagram?
2. Algorithms
Consider the following procedure Gnarly, which returns true or false. Notice the indenting
on lines 04-05: they execute only when the test on line 03 succeeds. You can assume that
n≥1 and that extracting a subarray (e.g. in the recursive calls in line 06) requires only
constant time.
01 Gnarly (a1,...,an: array of integers)
02 if (n= 1) return true
03 else if (n= 2)
04 if (a1=a2) return true
05 else return false
06 else if (Gnarly(a1,...,an−1) and Gnarly(a2,...,an)) return true
07 else return false
(a) If Gnarly returns true, what must be true of the values in the input array? Briefly
justify your answer.
(b) Express T(n), the running time of Gnarly on an input of length n, as a recurrence.
Be sure to include an initial condition.
(c) Give a big-theta bound on the running time of Gnarly. For full credit, you must show
work or briefly explain your answer.
3. Counting
(a) Suppose a set Shas 11 elements. How many subsets of Shave an even number
of elements? Express your answer as a summation. (You do not need to simplify
expressions involving permutations and/or combinations.)
(b) If x, y, z ∈N, how many solutions are there to the equation x+y+z= 25?
(c) Suppose that Ais a set containing pelements and Bis a set containing nelements.
How many functions are there from Ato P(B)? How many of these functions are
one-to-one?
1
pf3

Partial preview of the text

Download CS 173: Discrete Structures - Final Review Problems - Prof. Margaret M. Fleck and more Study notes Discrete Structures and Graph Theory in PDF only on Docsity!

CS 173: Discrete Structures, Spring 2012

Final Review Problems

These problems should not be turned in. They are to help you review for the final.

  1. Counting problems

(a) Let M = {a, b, c, d}. How many different partitions of M are there? (b) In the game Tic-tac-toe (played on the usual 3 by 3 grid), how many different board configurations are possible after four moves (i.e. two moves by each player)? (c) Suppose we have a state diagram with n states and k different actions. In how many different ways could we construct a transition function for this diagram?

  1. Algorithms Consider the following procedure Gnarly, which returns true or false. Notice the indenting on lines 04-05: they execute only when the test on line 03 succeeds. You can assume that n ≥ 1 and that extracting a subarray (e.g. in the recursive calls in line 06) requires only constant time.

01 Gnarly (a 1 ,... , an: array of integers) 02 if (n = 1) return true 03 else if (n = 2) 04 if (a 1 = a 2 ) return true 05 else return false 06 else if (Gnarly(a 1 ,... , an− 1 ) and Gnarly(a 2 ,... , an)) return true 07 else return false (a) If Gnarly returns true, what must be true of the values in the input array? Briefly justify your answer. (b) Express T (n), the running time of Gnarly on an input of length n, as a recurrence. Be sure to include an initial condition. (c) Give a big-theta bound on the running time of Gnarly. For full credit, you must show work or briefly explain your answer.

  1. Counting

(a) Suppose a set S has 11 elements. How many subsets of S have an even number of elements? Express your answer as a summation. (You do not need to simplify expressions involving permutations and/or combinations.) (b) If x, y, z ∈ N, how many solutions are there to the equation x + y + z = 25? (c) Suppose that A is a set containing p elements and B is a set containing n elements. How many functions are there from A to P(B)? How many of these functions are one-to-one?

  1. Binomial theorem

(a) How many terms are contained in (x + y + z)^30 after carrying out all multiplications, but before collecting like terms? (b) How many terms are contained in (x + y + z)^30 after carrying out all multiplications and collecting like terms? (c) What is the coefficient of the x^15 y^6 z^9 term? (You may leave you answer in terms of factorials!)

  1. Power sets

Suppose you were given the following sets:

A = {Vine, Tree, Shrub} B = {{Tree}} C = {Vine, Moss} D = {Red, Green} E = {Red}

For the following expressions, list the elements of the set or give the cardinality (as appropriate):

(a) D × C (b) P(B ∪ E) (c) |A × P(A ∪ D) | (d) {S ∈ P(A ∪ D) : |S| is a multiple of 4} (e) P(P(P(∅)))

  1. Planar graphs

(a) Suppose that G is an undirected connected simple planar graph with 10 vertices, all of degree 4. How many edges does it have? Use Euler’s formula and the Handshaking Theorem to calculate how many regions it has. (b) Show that this graph is planar by redrawing it without crossings: