In the backtracking algorithm for SAT, suppose that we always choose a subproblem (CNF formula) that has a clause that is as small as possible; and we expand it along a variable that appears in this small clause. Show that this is a polynomial-time algorithm in the special case in which the input formula has only clauses with two literals (that is, it is an instance of 2SAT).

Short Answer

Expert verified

The given algorithm is proved

Step by step solution

01

 Step 1: 

A backtracking algorithm is aproblem-solving algorithm that uses a brute force approach for finding the desired output.The Brute force approach tries out all the possible solutions and chooses the desired/best solutions.

The term backtracking suggests that if the current solution is not suitable, then backtrack and try other solutions.

02

 Step 2: 

XLet us first consider an example, say the following formula φ.

(XY)(Z¬Y)(X)(¬X¬Y)(WZ)(¬ZW)(¬U¬W)(¬ZU)

To understand why the proposed algorithm solves 2-SAT in polynomial time, let us see what happens

Sinceφ is satisifiable if and only if is assigned true, we get a residual formula –

(Z¬Y)(¬Y)(WZ)(¬ZW)(¬U¬W)(¬ZU)

Note that every clause that remains is either a unit clause, or was present in φoriginally. In general, this is also the case,

if all the clauses of the same size, we chose just one variable randomly and then expand on it, and get that every clause that remains is either a unit clause or was present in φoriginally.

When unit clauses are present, we expand on those variables, by the algorithm. In this example, we see that Y must be assigned false, and expanding we get: 2

(WZ)(¬ZW)(¬U¬W)(¬ZU)

Again, the remaining non-unit clauses were all present inφ ;

in fact, this must be the case since the algorithm modifies clauses by deleting literals. Crucially, because of this fact, the residual formula is satisfiable if and only ifφ was. Thus, there is no need to backtrack, and 2-SAT can be solved by a linear sequence of linear expansions.

In the original backtracking algorithm, this corresponds to skipping the second call to expand whenever the first call returns a non-empty result.

Unlock Step-by-Step Solutions & Ace Your Exams!

  • Full Textbook Solutions

    Get detailed explanations and key concepts

  • Unlimited Al creation

    Al flashcards, explanations, exams and more...

  • Ads-free access

    To over 500 millions flashcards

  • Money-back guarantee

    We refund you if you fail your exam.

Over 30 million students worldwide already upgrade their learning with Vaia!

One App. One Place for Learning.

All the tools & learning materials you need for study success - in one app.

Get started for free

Most popular questions from this chapter

Local search for minimum spanning trees. Consider the set of all spanning trees (not just minimum ones) of a weighted, connected, undirected graphG=(V,E).

Recall from Section 5.1 that adding an edge to a spanning treeT creates an unique cycle, and subsequently removing any other edgee'e from this cycle gives back a different spanning treeT' . We will say that differ by a single edge swap (e,e')and that they are neighbors.

a) Show that it is possible to move from any spanning tree Tto any other spanning tree T' by performing a series of edge-swaps, that is, by moving from neighbor to neighbor. At most how many edge-swaps are needed?

(b) Show that ifT' is an MST, then it is possible to choose these swaps so that the costs of the spanning trees encountered along the way are nonincreasing. In other words, if the sequence of spanning trees encountered is

T=T0T1T2···Tk=T',

then cost(Ti+1)cost(Ti)foralli<k.

(c) Consider the following local search algorithm which is given as input an undirected graph G.

Let Tbe any spanning tree of G

while there is an edge-swap(e,e') which reduces cost(T):

TT+ee'returnT

Show that this procedure always returns a minimum spanning tree. At most how many iterations does it take ?

In the MAXIMUM CUT problem we are given an undirected graphG=(V,E) with a weightw(e) on each edge, and we wish to separate the vertices into two sets S and V − S so that the total weight of the edges between the two sets is as large as possible. For eachSV definew(S) to be the sum of allwe over all edges{u,v} such that |Su,v|=1. Obviously, MAX CUT is about maximizing w(S) over all subsets of .

Consider the following local search algorithm for MAX CUT:

start with anySV

while there is a subsetS'V such that

||S 0 | − |S|| = 1 andw(S')>w(S) do:

set S=S'

  1. Show that this is an approximation algorithm for MAX CUT with ratio2.

(b) But is it a polynomial-time algorithm?

In the MAX SAT problem, we are given a set of clauses, and we want to find an assignment that satisfies as many of them as possible.

(a) Show that if this problem can be solved in polynomial time, then so can SAT.

(b) Here’s a very naive algorithm.

for each variable:

set its value to either0or1 by flipping a coin

Suppose the input has m clauses, of which thejth haskj literals. Show that the expected number of clauses satisfied by this simple algorithm is

j=1m1-12k   m2

In other words, this is a 2-approximation in expectation! And if the clauses all contain literals, then this approximation factor improves to 1+1/2k1.

(c) Can you make this algorithm deterministic? (Hint: Instead of flipping a coin for each variable, select the value that satisfies the most of the as of yet unsatisfied clauses. What fraction of the clauses is satisfied in the end?)

Devise a branch-and-bound algorithm for the SET COVER problem. This entails deciding:

(a) What is a subproblem?

(b) How do you choose a subproblem to expand?

(c) How do you expand a subproblem?

(d) What is an appropriate lowerbound

Do you think that your choices above will work well on typical instances of the problem? Why?

In the MULTIWAY CUT problem, the input is an undirected graphG=(V,E) and a set of terminal nodess1,s2,...,skV. The goal is to find the minimum set of edges in whose removal leaves all terminals in different components.

(a) Show that this problem can be solved exactly in polynomial time when k=2.

(b) Give an approximation algorithm with ratio at most2 for the case k=3.

(c) Design a local search algorithm for multiway cut.

See all solutions

Recommended explanations on Computer Science Textbooks

View all explanations

What do you think about this solution?

We value your feedback to improve our textbook solutions.

Study anywhere. Anytime. Across all devices.

Sign-up for free