Example

Given an undirected graph on vertices and edges, find a set of minimum size such that each edge of has at least one-endpoint in .

Brute Force Algorithm

  • Runs in time
  • Try all subsets of in increasing order of size of subsets.
  • For each choice , check in time if is a vertex cover or not

Can we design an algorithm for some

  • Say time algorithm ?
  • Does this violate
    • No, even if does not violate .

Designing an algorithm for some

  • Observation: No point adding a vertex of degree in the vertex cover
    • Might as well add it’s unique neighbour
  • Pick a vertex of degree
    • If we pick in the vertex cover, then the number of vertices reduces by
    • If we do not pick in the vertex cover, then the number of vertices reduces by at least
      • Not picking all of its neighbours have to be picked into the vertex cover
      • has at least two neighbours
  • time needed to solve on graphs with vertices
    • Base case
  • Then, we have the recurrence
    • We solve both instances, and take the minimum of the two values
    • Hence, the running time is
    • This is a linear homogenous recurrence
    • Linear = terms on the right hand side are raise to power one
    • Homogenous = no constants on the right hand side
  • The standard way to solve such recurrences is to set , and then determine the value of
    • Hence, our recurrence reduces to
    • Taking out as common term throughout, we get
    • This equation is satisfied for all
    • Hence, is an upper bound for our branching algorithm.

Faster algorithm for 3-SAT

  • is a special case of the CNF-SAT problem where

    • Each clause has at most three literals
    • Instance of : Is satisfiable ?
    • is also NP-hard
  • Simplifying assumptions: Each clause has exactly 3 literals

  • Let be number of variables and be number of clauses

  • Brute Force tries all truth assignments, and for each truth assignment checks in time if each of the clauses is satisfied

  • So, total running time is

  • Consider a clause for a given instance of

    • For the instance to be satisfiable at least one out of has to be TRUE