1 / 22

Final Review

Final Review. Chris and Virginia. Overview. One big multi-part question. (Likely to be on data structures) Many small questions. (Similar to those in midterm 2) A few questions from the homework and class. (This slide is on the class webpage). You need to able to.

joey
Download Presentation

Final Review

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Final Review Chris and Virginia

  2. Overview • One big multi-part question. (Likely to be on data structures) • Many small questions. (Similar to those in midterm 2) • A few questions from the homework and class. • (This slide is on the class webpage)

  3. You need to able to • Summarize what we learned. • Recognize false proofs. • Use appropriate data structures. • Invent new data structures. • Design new (e.g. randomized) algorithms. • Know NP, coNP, NP-completeness, approximation algorithms • Matching, Graphs, and random walk.

  4. Summarize what we learned. • Given a problem that appeared in class or homework, • Describe the approach to solve the problem • Summarize the answer in 100 words or less. • You do NOT need to remember the whole answer. We will NOT ask you to repeat the entire solution.

  5. Example: Planar 5 coloring

  6. Example: Planar 5 coloring • Find v, any vertex of degree 5 or less. • Always possible, since |E| < 6 |V| in planar graph. • Merge x, y such that(v, x) in E, (v, y) in E, but (x, y) not in E • We can always find x, y, since planar graph has no 5-clique. • Merge x and y, and remove v. • v will has only 4 neighbors, so there always exists a color for v • Repeat Step 1 until there are no vertices • Color the vertices in reverse order of removal.

  7. Recognize false proofs/argument • “Proof”: The above algorithm clearly runs in O(n).

  8. Recognize false proofs/argument • “Proof”: The above algorithm clearly runs in O(n). • Problem in step 2: “Find x, y such that(v, x) in E, (v, y) in E, but (x, y) not in E.” • we don’t have adj. matrix to query in O(1) • we can not afford to construct adj. matrix since we only have O(n) total • (Btw, this is not good answer, and Manuel would not let me put something ambiguous on the final.)

  9. What data structure to use? • You need Insert(x), Delete(x) and Find(x), and you query a small subset of all the elements very frequently.

  10. What data structure to use? • You need Insert(x), Delete(x) and Find(x), and you query a small subset of all the elements very frequently. • Splay tree, because splay tree moves recently accessed node to the top, so it is cheaper to access it again.

  11. What data structure to use? • You need Insert(x), Delete(x) and Findmin(x), and Findmax(x).

  12. What data structure to use? • You need Insert(x), Delete(x) and Findmin(x), and Findmax(x). • If a pointer to x is given for delete • Use a maxheap and a minheap. • If not, • Use a binary search tree and maintain the pointers to min and max elements.

  13. What data structure to use? • You need Insert(x), Delete(x) (given pointer to x) and FindMedian().

  14. What data structure to use? • You need Insert(x), Delete(x) (given pointer to x) and FindMedian(). • Use two heaps. A maxheap to store everything less than the median, and a minheap to store everything greater than the median.

  15. Prove lower bound • Can you design a data structure where Insert(x), Delete(x) and FindMedian() are all little o(log n)?

  16. Prove lower bound • Can you design a data structure where Insert(x), Delete(x) and FindMedian() are all little o(log n)? • No. • Sorting lower bounds: Any algorithm that sorts the set of elements, S, must perform at least Omega(|S| log |S|) comparisons between elements of S.

  17. Decision problems, NP and coNPNP-hardness and completeness • Example: MINSAT Given a formula in CNF and an integer K, is there an assignment which satisfies at mostK clauses. (no restriction on clause size, except that the literals are distinct; no duplicate clauses)

  18. MINSAT cont. • Reduction from Vertex Cover (VC). • Given [G=(V,E), K] instance of VC. • Direct the edges arbitrarily. • Create a clause Cu for each vertex u • For (u,v) add xuvto Cu and ¬xuvto Cv.

  19. Approximation Algorithms • Approximation Ratio: Malg/Mopt • Example: 2-approximation for MINSAT • Convert to VC: • A vertex for each clause • Edge between clauses if they have conflicting literals: x and ¬x. • Approximate VC instance.

  20. Planarity • You should know: • Planar graph definition, duals, properties • Planarity testing/planar embedding in linear time • Planar Separator Theorem: finding a small separator in linear time

  21. Planarity • Example: • a (1/3,2/3)-separator of size 2 for outerplanar graphs • A graph is outerplanar if it has a plane embedding so that all vertices are on the outer face

  22. Outerplanar Separator • Given the outerplanar embedding of G, triangulate all inner faces. • Create the plane dual, except for the vertex of the outer face; this is a TREE of degree at most 3. • Find (1/3,2/3)-edge separator of the tree. • Remove the two vertices of the corresponding edge in G – this is the separator.

More Related