UCSD CSE 21, Spring 2014 [Section B00] Mathematics for Algorithm and System Analysis Final Exam Review Session Class URL: http://vlsicad.ucsd.edu/courses/cse21-s14/
Notes 140608 Review Things to Know has been updated Decision trees to be added? Practice final questions see both ABK, RRR sets Review your HWs, quizzes, and MTs as well, of course! Finals week OHs: see Piazza Final exam Two handwritten (both sides) sheets of 8.5 x 11 paper allowed, no electronics 15 q s on final 10 q s common across sections (details not worked out) 110 points available, perfect = 100 OK from RRR this past Friday: Section B00 grade computed as max(final-only, normally-computed) TED scores updated except for poker chip credits If you see an error, contact David / Natalie Agenda for today ~20-25 example questions that should help keep you on the right study track for the actual 15 questions on final
Final Exam Topics (#q s) A topic at least one question 1. Counting: rearrangements, product keys, order form (3) 2. Functions and permutations: {in,sur,bi}jections, composition (1) 3. Probability and expectation (2) 4. Bayes rule, conditional probability, independence (1) 5. Recurrences: D/Q and Master Theorem; lhcc (lnhcc) (2) 6. Asymptotic complexity (working with big-o/ /, log vs. polynomial vs. exponential) (1) 7. Complexity zoo (P, NP, NP-hard, NP-complete) (1) 8. Graphs I (graph computations): MST, shortest paths (2) 9. Graphs II (graph types and properties): tree, bipartite; isomorphism, chromatic number, Eulerian, Hamiltonian (2) Comment: Topics 1, 2, 3, 4, 8 (9) can often overlap or combine! Comment: RRR likes decision tree questions
Topic 1 Example 1 How many different strings can be formed using all nine letters of the word EXCELLENT? How many different 3-letter strings can be formed from the letters of the word EXCELLENT if no letter can be repeated more times than it appears in the original word?
Topic 1 Example 2 How many different combinations of pennies, nickels, dimes and quarters can a piggy bank contain if it has 20 coins in it, including at least one quarter, at least two dimes, at least three nickels and at least four pennies?
Topic 1 Example 3 How many strings of three English letters have no consecutive letters the same? How many strings of three English letters have exactly two letters that are A s? How many strings of three English letters contain at most one vowel and at most one J?
Topic 2 Example 1 Consider the set A = {1, 2, 3, 4}. How many functions f: A A are not permutations? #functions = #permutations =
Topic 2 Example 2 (RRR F32,33,34) How many possible surjections are there from {1,2,3,4} {A,B}? How many possible injections are there from {1,2,3,4} {A,B}? How many possible injections are there from {A,B} {1,2,3,4}??
Topic 2 Example 3 (RRR F24) What is [(1,2,3,4) (1,2)(3,5)] -1? Express your answer in cycle notation.
Topic 2 Example 4 (~RRR F26) A teacher has four students who take an exam. He asks students to grade each others exams, such that each student grades exactly one exam and no student grades his/her own exam. In how many ways can this be done?
Topic 3 Example 1 If A and B are events in a probability space with Pr(A) = 1/3, Pr(B) = 1/4, and Pr((A B) c ) = 11/12, what is Pr((A B) c )?
Topic 3 Example 2 What is the expected sum of the numbers that appear when three fair six-sided dice are rolled?
Topic 3 Example 3(a) Consider a random graph G(V, E) where V has 8 vertices and for each vertex pair u,w V the edge (u,w) exists with probability p = 0.5. What is the expected number of edges in G? What is the expected number of K 4 subgraphs in G?
Topic 3 Example 3(b) Consider a random bipartite graph B(V 1, V 2, E) where V 1 has 5 vertices, V 2 has 3 vertices, and for each vertex pair u,w with u V 1, w V 2 the edge (u,w) exists with probability p = 0.2 What is the expected number of edges in G? What is the probability that G has exactly 5 edges? What is the expected number of triangles in G?
Topic 3 Example 4 Suppose that we flip a fair coin until it either comes up tails twice (not necessarily consecutively) or we have flipped it four times. What is the expected number of times we flip the coin?
Topic 4 Example 1(a) A Discrete Joint Probability (Pete s discussion slide) X\Y X=0 X=1 X=2 Sum Y=0.05.1.15.3 Y=1.15.05.15.35 Y=2.2.05.1.35 Sum.4.2.4 1 What is Pr(Y = 1)? What is Pr( Y = 2 X = 0 )?
Given: Pr(Y = 2 X = 0) =.5 Pr(Y = 2) =.35 Pr(X = 0) =.4 Topic 4 Example 1(b) What is P(X = 0 Y = 2)? Express as a fraction in lowest terms.
Topic 4 Example 2 Suppose that a Bayesian spam filter is trained on a set of 10000 spam messages and 5000 messages that are not spam. The word herbal appears in 800 spam messages and 200 messages that are not spam. 50% of the incoming email messages to the inbox are spam. Find an expression for the probability that a received message containing the word herbal is spam.
Topic 4 Example 3(a) What is the conditional probability that when a fair coin is flipped four times, at least two consecutive heads will come up, given that the first flip came up tails?
Topic 4 Example 3(b) Let E be the event that when a fair coin is flipped four times, exactly one head comes up. Let F be the event that when a fair coin is flipped four times, the first flip is heads. Are E and F independent? Justify. RRR F36: Let P(A) = 0.3, P(A B) = 0.7, and P(B c ) = 0.6. Are A and B independent events?
Topic 5 Example 1 Define the recurrence a n = 6a n-1 8a n-2 for n 2, with a 0 = 0 and a 1 = 2. Find an explicit closed-form solution for a n. Which of the following big-o classes is a n in? (a) O(n) (b) O(n 2 ) (c) O(2 n ) (d) O(4 n ) (e) None of above.
Topic 5 Example 2 Give the general solution to the recurrence x(n+2) = 6x(n+1) 9x(n), n 0, with x(0) = 0, x(1) = 1.
Topic 5 Example 3 Suppose that a divide-and-conquer algorithm s runtime on instances of size n is governed by the recurrence T(n) = 8T(n/2) + O(n 2 ). Apply the Master Theorem and give the resulting big-o expression for T(n). Suppose that a divide-and-conquer algorithm s runtime on instances of size n is governed by the recurrence T(n) = 7T(n/2) + O(n 2 ). Apply the Master Theorem and give the resulting big-o expression for T(n).
Topic 5 Example 4 Give the closed-form solution to T(n) = T(n-1) + 3, where T(0) = 1. Give the closed-form solution to T(n) = T(n-1) + 2n, where T(0) = 1.
Topic 6 Example 1 You are given that f O(r) and g O(s). Justify the claim that f+g is O(r+s). You are given that f O(g) and g O(h). Justify the claim that f O(h). Let f(x) = 1000x 2, g(x) = 10x 3. Justify the claim that f O(g).
Topic 7 Example 1 The Isomorphism(G,H) decision problem is: Given two graphs G and H, does there exist an isomorphism between G and H? Explain why Isomorphism(G,H) is in the class NP **IF** it were known that Isomorphism(G,H) was an NP-hard problem, would Isomorphism(G,H) be NP-complete?
Topic 7 Example 2 The EC(G) decision problem is: Given a graph G, does G contain an Euler circuit? Explain why EC(G) is in the class P **IF** it were known that EC(G) was an NP-hard problem, would EC(G) be NP-complete?
Topics 8/9 Example 1(a) Consider the following pair of graphs. Are these graphs isomorphic? Explain.
Topics 8/9 Example 1(b) Consider the following pair of graphs. For each graph: (i) is the graph Eulerian? (ii) does the graph contain an Eulerian trail? (iii) is the graph Hamiltonian?
Topics 8/9 Example 2(a) Consider the following graph with positive edge weights. What are the first three edges found by Kruskal s MST algorithm?
Topics 8/9 Example 2(b) Consider the following graph with positive edge weights. What are the first four edges found by Prim s MST algorithm starting at the vertex v 0? What are the first four edges found by Prim s MST algorithm starting at the vertex v 5?
Topics 8/9 Example 2(c) Consider the following graph with positive edge weights. Give, in order, the first four vertices from which the search parties will call home in Dijkstra s shortest-paths algorithm, if the algorithm starts from vertex v 0.
Succinct Certificates If I claim to have a solution, can I prove its correctness to you in polynomial time? How do I prove that a number is composite? Can you check my proof easily? How do I prove that there is a Hamiltonian cycle in a given graph? Can you check my proof easily? How do I prove that there is a TSP tour of cost in a given graph? Can you check my proof easily? How do I prove that a given graph can be colored using at most 5 colors? Can you check my proof easily?
The Classes P and NP Classes of Decision Problems P: Problems for which there exists a deterministic polynomial-time algorithm NP: Problems for which there exists a nondeterministic polynomial-time algorithm non-deterministic polynomial-time Solutions are small (== polynomial-size) Guessing is free Solutions must be checkable in polynomial time (== succinct certificate ) P NP (why??) but whether P = NP is not known Most people believe P NP, which would imply P NP
NP-Hard, NP-Complete NP-Hard: Problem X is NP-hard if every problem in NP is polynomially reducible to X Solving any problem in NP can be boiled down to solving X X is at least as hard as any problem in NP NP-Complete: Problem X is NP-complete if: X is NP-hard, and X is in NP The hardest problems in NP