Exam grade:100 Flashcards

1
Q

Hamilton cycle

A
  • Each vertex has two edges, one in and one out.
  • If we could have an algorithm in polynomial time which tells us whether a graph has or hasn’t an Hamilton graph, we could test all the possiblities of a vertex having exactly 2 edges to see when the algorithm returns YES. Then save them and proceed to the next vertex.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

NPC Reductions

A

We should only think of an instance of the problem we are transforming into. We take an arbitrary case of problem A and transform it to some case, which can be specific case, of problem B.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Main point is that for a verifer to “work” in polynomial time, the length of the certificate must be also polynomial in the length of the encoding of G.

That is, if the encoding of g is n, then the length of the certificate should be bounded by O(n^k), for some k.

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q
  • Explain the reduction from 3SAT to CLIQUE*
  • Explain the reduction from CLIQUE to VERTEX-COVER*
A
  • Each literal represents a vertex.
  • Each vertrex is connected with all the other vertices that follow 2 conditions:
    • they do not belong to its clause
    • they don’t represent the value of v’s literals’ complement
  • NOTE: the clique is of the size of the number of clauses in 3SAT.
  • Given the set G=(V,E) with QLIQUE of size k.
  • Create the contrary graph (G’ = V,E’)
  • Determine whether exists a vertex cover of size |V|-k.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Reduction from HAM-CYCLE(G=(V,E)) to TSP(G’,c,k)

NOTE: G’ is always a complete graph

A
  • Given a graph we should determine using TSP(G,c,k) if there exists an hamilotanian path.
  • G’ = (V,E’), E’ = all possible vertices
  • we set c(i,j) = 0 if (i,j) belongs to E
  • we set c(i,j) = 1 if (i,j) does not belong to E.

Now the important part! we set k to 0. That is, we force the traveler to move only within the edges of E. So that the price he pays will cost at most 0.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q
  • 3CNF - 01IP*
  • What did you learn from this reduction*?
A

Main points:

  • we must express xi and xi’ individually.
    • that’s why they reserved place of 2n.
    • if the ith place variable is true, than the (n+i)th variable must be false and vice versa.
  • we must enforce the condition that exactly one of xi and xi’ is true.
    • Think of how to “fail” if both are true
    • Think of how to “fail” if both are false
    • else, think of how to “pass”
  • we must enforce the condition that if each clause is true we return true, else false.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

3CNF to subset-problem

A
  • sum of xi and xi’ must equal 1
  • sum of value in a clause belong to {1,2,3}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Show how to solve the subset-sum problem in polynomial time if the target value t
is expressed in unary.

A

Two main properties taken from this question:

  • The run-time depends on the length of the input. Since the length of the input is O(t), and not O(log(t)), a running time of O(nt) is polynomial a not exponential.
  • Each operation on a log(t) length number takes log(t)
  • We can use dynamic programming also if we search for an exact solution. We set one base case to return true, and the other to return false.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Important points regarding this reduction

A
  • Usually its a good idea to “walk away” from the field of the first instance. If we were to make just m clauses of “F”. we were wrong. because if all the clauses are false, and y = 1 we have a solution.
  • Another use of walking away is creating ourselves a new variable.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Important note aboute degree 2 vertices.

A

Each vertex is contained within a simple cycle.

we can view the graph as disjoint sets of cycles.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Greedy algorithm: when you need to choose an element to some group, what should you you verify?

A
  • You should verify that the element holds a special characterization within the chosen elements.
  • You should verify that the group its been added to holds a speical property that makes it a designated one.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Critical point in Kruskal and Prim

A
  • Both algorithms rely on the assumption all the desired edges can be added to the graph.*
  • If we make restrictions, we might not allow to add critical edges in the tree - thus making the algorithms wrong.*
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

When dealing with cuts and bi-graphs use the intersection notation to divide each problem into different cases.

A
17
Q

Usually in linear programming when we want to prove that OPT(of dynamic problem)<=FRAC(linear problem), we show that OPT suggests a solution for the linear problem, and because FRAC is the optimal solution, the inequality applies.

A
18
Q

When you prove an algorithm correctness in inductiom, think of all the possible cases that might happen, and prove each seperately.

A
19
Q

You often confuse with FRAC thinking it has only integer value. Recall, we’re talking about a program above the reals.

A
20
Q
  • The way to “move” from FRAC to OPT is by using random variables. You need to show how that the expected value is defined using the results of FRAC.*
  • Steps:*
    1. Think of the problem in terms of [0,1] - natural numbers.*
    1. Now, assume that Yi = 1 means “good” Yi=0 means “bad”.*
    1. With reals, Yi>0 means there’s a chance of “Yi” for Yi to be “good”.*
    1. You should prove that Probability[Yi==”good”]<=Yi*
    1. After that, build the expected value where each such probability is a random variable.*
    1. Prove the main fact by stating that for an expected value of x there must be an event with value at most x and an event with value at least x.*
  • That is, OPT<frac></frac>*
A
21
Q

What does it tell you that a language belong to LP

A
  • There exists a verifer V and polynomial P s.t.
    • if x is in L, there exists some certificate y:
      • |y|<=|x^c|, for some natural c.
      • V(x,y) returns true
22
Q
  • Great point regarding Hamilton cycle.*
  • If we create a new vertex that shares exactly two edges, one with vertet s and one with vertex t. What is the benefit of that?*
A

What we do is we force the hamilton cycle to start with s and end with the edge (t,s). That is, now, if there exists an hamiton path, it must start with s and end with t. That’s because it must get to x and x is shared between the two.

23
Q
  • Major difference between Hamilton path and Hamilton cycle is that in a cycle it doesn’t matter where you start whereas with a path it sure does.*
  • So, when doing reduction to an Hamilton path “s, t”, it is important who that s is. some vertices you start with might find an hamilton path and some don’t,*
A
24
Q

Useful tool when dealing with NAE-3SAT

A

ההצבה ההפוכה להצבה מספקת-לא מספקת היא גם כן הצבה מספקת -לא מספקת

25
Q

at least 3 literals<= exactly 3 literals

A
  • Assume we have x1,x2,x3,x4,x5*
  • define |x-2| yi’s* , do:
  • (x1 OR x2 OR y1)*
  • AND*
  • (NOT(y1) OR x3 OR y2)*
  • AND*
  • (NOT(y2) OR x4 OR x5)*
26
Q

Each of the M constraints in the primal has a new coefficient in the dual, and each of the n constraints in the dual has a coefficient in the primal

A