Docsity

CS 173 Final Exam: Instructions and Problems - Prof. Margaret M. Fleck, Exams of Discrete Structures and Graph Theory

Partial preview of the text

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

CS 173, Final Exam

14 December 2010

Fill in your name, netid, and discussion section time below. Also write your name or netid on the last page (which sometimes gets pulled off).

NAME:

NETID:

DISCUSSION DAY/TIME:

Problem 1 2 3 4 5 total 1-

Possible 8 9 12 8 10 47

Score

Problem 6 7 8 9 10 total 6-

Possible 12 10 11 8 12 53

Score

Total out of 100 points

INSTRUCTIONS: please read carefully)

  • There are 10 problems, each on a single page. Make sure you have a complete exam.
  • The point value of each problem is indicated next to the problem.
  • It is wise to skim all problems and point values first, to best plan your time.
  • Points may be deducted for solutions which are correct but excessively complicated, hard to understand, or poorly explained.
  • For proofs, be sure to use good mathematical style, with the steps in logical order.
  • Brief explanations and/or showing work may increase partial credit for buggy answers.
  • We expect most people to finish the exam in 2 hours, but you may take up to the full 3 hours.
  • Turn in your exam at the front. Show your ID to the proctors.
  • This is a closed book exam. No notes or electronic devices of any kind are allowed.
  • Except where explicitly indicated, it isn’t necessary to simplify or calculate out complex constant expressions such as (0.7)^3 (0.3)^5 , 03 ..^1575 , 7!,

7

, and the like.

  • Do all work in the space provided, using the backs of sheets if necessary. See the proctor if you need more paper.
  • Please bring any apparent bugs to the attention of the proctors.
  • After the exam is over, discuss its contents with other students only after verifying that they have also taken the exam (e.g. they aren’t about to take a conflict exam).

Problem 2: Short answer (9 points)

(a) (5 points) Check all boxes which correctly characterize this relation leaving the other boxes blank. (If you change your answer, make it very clear when you’ve meant to uncheck a box.)

F A

B

C

E D

Reflexive: Irreflexive:

Symmetric: Antisymmetric:

Transitive:

(b) (4 points) Suppose that T is the subset of Z^2 defined by the following recursive rules:

rule 1) (2, 0) is in T rule 2) If (x, y) is in T , then (x, y + 1) is in T. rule 3) If (x, y) and (a, b) are in T , then (x + a, y + b) is in T.

Give a closed-form (i.e. non-recursive) definition of T using set-builder notation. Show your work or briefly explain why your closed form is correct.

Problem 3: Short answer (12 points)

(a) (4 points) Suppose that R is a relation on a set A. Using precise mathematical language, define what it means for R to be antisymmetric.

(b) (4 points) Suppose that the equivalence relation ∼ on Z is defined such that x ∼ y if and only if 5|(2x + 3y). List four members of the equivalence class [7].

(c) (4 points) Suppose that A = { 4 } and B = { 8 , 9 }. List the elements of P(P(A)) × B.

Problem 5: Counting (10 points)

(a) (4 points) When playing the game “Faculty Wars,” your battlegroup is a set of 10 characters. Each character can be either a Dean, a Department Head, a Professor, a Lecturer, or a TA. You can choose any number (including zero) of each character type. In how many different ways can you form your battlegroup?

(b) (6 points) A domino consists of two squares (“ends”). Each end may be blank or may contain between one and n spots. A domino may have the same number of spots on both ends, or different numbers of spots on the two ends. A double-n domino set contains exactly one of each possible dot combination, where the order of the two ends doesn’t matter. For example, a double-two domino set would contain: (0, 0), (1, 0), (2, 0), (1, 1), (1, 2), (2, 2). How many dominoes are there in a double-n set? Show your work or explain why your formula is correct.

Problem 6: Short proofs (12 points)

(a) (6 points) Let’s define the relation T on R^2 as follows

(a, b) T (c, d) if and only if c − a ≥ 3 and d − b ≥ 3.

Prove that T is transitive.

(b) (6 points) Prove that 4n^3 + n is O(n^3 ). Prove this directly from the definition of what it means for a function f to be O(g), where g is another function. Give details of the algebra and make sure that your algebraic steps are in logical order.

Problem 8: Functions (11 points)

Suppose that A, B, and C are sets and suppose we have two functions f : A → B and g : B → C. Also recall the definition of g ◦ f : it’s the function from A to C defined by (g ◦ f )(x) = g(f (x)).

(a) (6 points) Prove the following claim: if f is one-to-one and g is one-to-one, then g ◦ f is one-to-one.

(b) (5 points) Suppose we know that g ◦ f is onto. Professor Flitwick claims that f must be onto. Show that Professor Flitwick is wrong using a concrete counter-example in which A, B, and C are all finite sets.

Problem 9: Algorithm analysis (8 points)

The procedure crunch takes an array of integers a 1 , a 2 ,... , an (where n ≥ 1) and returns an integer. Here is its pseudo-code. Assume that dividing the array in two (line 6) requires only constant time. 1 crunch(a 1 ,... , an : array of integers) 2 if (n = 1 and a 1 ≥ 0) return 1 3 else if (n = 1) return 0 4 else 5 m = ⌊n 2 ⌋ 6 output = crunch(a 1 ,... , am) + crunch(am+1,... , an) 7 return output

(a) (2 points) Give a succinct English description of what crunch computes.

(b) (3 points) Suppose that T (n) is the running time of crunch on an input array of length n. Write down a recurrence for T (n), including a base case. For simplicity, you may assume that n is a power of 2.

(c) (3 points) What is the big-Θ running time of crunch? Justify your answer, e.g. by unrolling your recurrence or by drawing a (well-labelled) recursion tree.