final review

22
Final Review Chris and Virginia

Upload: joey

Post on 19-Jan-2016

24 views

Category:

Documents


0 download

DESCRIPTION

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. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Final Review

Final Review

Chris and Virginia

Page 2: Final Review

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)

Page 3: Final Review

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.

Page 4: Final Review

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.

Page 5: Final Review

Example: Planar 5 coloring

Page 6: Final Review

Example: Planar 5 coloring

1) Find v, any vertex of degree 5 or less.– Always possible, since |E| < 6 |V| in planar graph.

2) 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.

3) Merge x and y, and remove v.– v will has only 4 neighbors, so there always exists a

color for v4) Repeat Step 1 until there are no vertices5) Color the vertices in reverse order of removal.

Page 7: Final Review

Recognize false proofs/argument

• “Proof”: The above algorithm clearly runs in O(n).

Page 8: Final Review

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.)

Page 9: Final Review

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.

Page 10: Final Review

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.

Page 11: Final Review

What data structure to use?

• You need Insert(x), Delete(x) and Findmin(x), and Findmax(x).

Page 12: Final Review

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.

Page 13: Final Review

What data structure to use?

• You need Insert(x), Delete(x) (given pointer to x) and FindMedian().

Page 14: Final Review

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.

Page 15: Final Review

Prove lower bound

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

Page 16: Final Review

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.

Page 17: Final Review

• Example: MINSAT

Given a formula in CNF and an integer K, is there an assignment which satisfies at most K clauses.

(no restriction on clause size, except that the literals are distinct; no duplicate clauses)

Decision problems, NP and coNPNP-hardness and completeness

Page 18: Final Review

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 xuv to Cu and ¬xuv to Cv.

Page 19: Final Review

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.

Page 20: Final Review

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

Page 21: Final Review

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

Page 22: Final Review

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.