cs20a np problems l.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
CS20a: NP problems PowerPoint Presentation
Download Presentation
CS20a: NP problems

Loading in 2 Seconds...

play fullscreen
1 / 37

CS20a: NP problems - PowerPoint PPT Presentation


  • 253 Views
  • Uploaded on

CS20a: NP problems. The SAT problem Graph theory. Time-bounded TMs. All tapes are 2-way infinite M is DTIME(T(n)) if M is deterministic For any input of length n, M takes at most T(n) steps M is NTIME(T(n)) Nondeterministic case. NP problems.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'CS20a: NP problems' - arleen


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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
cs20a np problems
CS20a: NP problems
  • The SAT problem
  • Graph theory

Computation, Computers, and Programs Recursive functions

http://www.cs.caltech.edu/courses/cs20/a/ March 10, 2014

time bounded tms
Time-bounded TMs
  • All tapes are 2-way infinite
  • M is DTIME(T(n)) if
    • M is deterministic
    • For any input of length n, M takes at most T(n) steps
  • M is NTIME(T(n))
    • Nondeterministic case

Computation, Computers, and Programs Recursive functions

http://www.cs.caltech.edu/courses/cs20/a/ March 10, 2014

np problems
NP problems
  • A problem is in NP if it can be decided yes/no by a nondeterministic TM in O(nc) steps
    • n is the length of the input
    • c is a constant
  • How long does it take to decide a problem in NP?
    • It takes O(nc) time to explore each possible nondeterministic choice
    • There are an exponential number of choices
    • So it takes O(2n) time worst case
  • How long does it take to verify an NP execution?
    • There are O(nc) steps of size O(nc)
    • So it takes O(n2c) time

Computation, Computers, and Programs Recursive functions

http://www.cs.caltech.edu/courses/cs20/a/ March 10, 2014

cnf satisfiability
CNF satisfiability

Computation, Computers, and Programs Recursive functions

http://www.cs.caltech.edu/courses/cs20/a/ March 10, 2014

satisfiability algorithm
Satisfiability algorithm
  • CNF should make the decision problem easier, since there is only conjunction, disjunction, negation
  • An algorithm in NP
    • Guess a truth assignment
    • Verify the assignment
  • An algorithm in P
    • Must be deterministic (no “guessing”)
    • Just figure out if the formula is true

Computation, Computers, and Programs Recursive functions

http://www.cs.caltech.edu/courses/cs20/a/ March 10, 2014

building an algorithm for 2sat
Building an algorithm for 2SAT

Computation, Computers, and Programs Recursive functions

http://www.cs.caltech.edu/courses/cs20/a/ March 10, 2014

2sat graph
2SAT graph

Computation, Computers, and Programs Recursive functions

http://www.cs.caltech.edu/courses/cs20/a/ March 10, 2014

graph theory
Graph theory
  • A graph is a set of points (vertices) that are interconnected by a set of lines (edges)

Computation, Computers, and Programs Recursive functions

http://www.cs.caltech.edu/courses/cs20/a/ March 10, 2014

some common graphs
Some common graphs

Computation, Computers, and Programs Recursive functions

http://www.cs.caltech.edu/courses/cs20/a/ March 10, 2014

formal definition of graphs
Formal definition of graphs

Computation, Computers, and Programs Recursive functions

http://www.cs.caltech.edu/courses/cs20/a/ March 10, 2014

graph definitions
Graph definitions

Computation, Computers, and Programs Recursive functions

http://www.cs.caltech.edu/courses/cs20/a/ March 10, 2014

a simple theorem
A simple theorem

Computation, Computers, and Programs Recursive functions

http://www.cs.caltech.edu/courses/cs20/a/ March 10, 2014

path definitions
Path definitions

Computation, Computers, and Programs Recursive functions

http://www.cs.caltech.edu/courses/cs20/a/ March 10, 2014

path example
Path example

Computation, Computers, and Programs Recursive functions

http://www.cs.caltech.edu/courses/cs20/a/ March 10, 2014

connected components
Connected components

Computation, Computers, and Programs Recursive functions

http://www.cs.caltech.edu/courses/cs20/a/ March 10, 2014

graph components
Graph components

Computation, Computers, and Programs Recursive functions

http://www.cs.caltech.edu/courses/cs20/a/ March 10, 2014

trees
Trees
  • A tree is a connected graph with no cycles
  • A forest is a set of trees

Computation, Computers, and Programs Recursive functions

http://www.cs.caltech.edu/courses/cs20/a/ March 10, 2014

directed graphs
Directed graphs
  • A directed graph assigns a direction to the edges

Computation, Computers, and Programs Recursive functions

http://www.cs.caltech.edu/courses/cs20/a/ March 10, 2014

paths cycles
Paths, cycles

Computation, Computers, and Programs Recursive functions

http://www.cs.caltech.edu/courses/cs20/a/ March 10, 2014

connected components20
Connected components

Computation, Computers, and Programs Recursive functions

http://www.cs.caltech.edu/courses/cs20/a/ March 10, 2014

graph algorithms depth first search dfs
Graph algorithms: Depth-First-Search (DFS)
  • DFS does the following:
    • Assigns a unique number to each vertex
    • Forms a spanning tree (called the DFS spanning tree)
  • Basic algorithm
    • We need a stack of edges (initially empty)
    • A counter c (initially 1)

Computation, Computers, and Programs Recursive functions

http://www.cs.caltech.edu/courses/cs20/a/ March 10, 2014

dfs algorithm
DFS algorithm

Computation, Computers, and Programs Recursive functions

http://www.cs.caltech.edu/courses/cs20/a/ March 10, 2014

dfs initial search
DFS: Initial search

Computation, Computers, and Programs Recursive functions

http://www.cs.caltech.edu/courses/cs20/a/ March 10, 2014

dfs backtracking
DFS: Backtracking

Computation, Computers, and Programs Recursive functions

http://www.cs.caltech.edu/courses/cs20/a/ March 10, 2014

dfs finalize
DFS: Finalize

Computation, Computers, and Programs Recursive functions

http://www.cs.caltech.edu/courses/cs20/a/ March 10, 2014

biconnected components
Biconnected components

Computation, Computers, and Programs Recursive functions

http://www.cs.caltech.edu/courses/cs20/a/ March 10, 2014

biconnected components27
Biconnected components

Computation, Computers, and Programs Recursive functions

http://www.cs.caltech.edu/courses/cs20/a/ March 10, 2014

transitive case part 1
Transitive case (part 1)

Computation, Computers, and Programs Recursive functions

http://www.cs.caltech.edu/courses/cs20/a/ March 10, 2014

transitive case part 2
Transitive case (part 2)

Computation, Computers, and Programs Recursive functions

http://www.cs.caltech.edu/courses/cs20/a/ March 10, 2014

articulation points
Articulation points

Computation, Computers, and Programs Recursive functions

http://www.cs.caltech.edu/courses/cs20/a/ March 10, 2014

articulation points31
Articulation points

Computation, Computers, and Programs Recursive functions

http://www.cs.caltech.edu/courses/cs20/a/ March 10, 2014

using dfs to get biconnected components
Using DFS to get biconnected components

Computation, Computers, and Programs Recursive functions

http://www.cs.caltech.edu/courses/cs20/a/ March 10, 2014

dfs backedges
DFS backedges

Computation, Computers, and Programs Recursive functions

http://www.cs.caltech.edu/courses/cs20/a/ March 10, 2014

dfs biconnected components
DFS biconnected components

Computation, Computers, and Programs Recursive functions

http://www.cs.caltech.edu/courses/cs20/a/ March 10, 2014

solving 2sat
Solving 2SAT
  • We can define DFS for directed graphs
    • Follow edges only in the forward direction
  • Use DFS to determine strongly-connected components
    • Strongly-connected component
      • For each u, v, there is a path from u to v, and from v to u

Computation, Computers, and Programs Recursive functions

http://www.cs.caltech.edu/courses/cs20/a/ March 10, 2014

2sat graph36
2SAT graph

Computation, Computers, and Programs Recursive functions

http://www.cs.caltech.edu/courses/cs20/a/ March 10, 2014

2sat solution
2SAT solution
  • The formula is satisfiable iff there is a strongly-connected component that contains A and not A for some letter A
    • If it does, then A implies not A and not A implies A (contradiction)
    • If not, we have to define a satisfying assignment (next time)

Computation, Computers, and Programs Recursive functions

http://www.cs.caltech.edu/courses/cs20/a/ March 10, 2014