David Evans Class 16: NP-Completeness / The Story so Far CS150: Computer Science University of Virginia Computer Science.

Slides:



Advertisements
Similar presentations
P, NP, NP-Complete Problems
Advertisements

Complexity. P=NP? Who knows? Who cares? Lets revisit some questions from last time – How many pairwise comparisons do I need to do to check if a sequence.
Introduction to Algorithms NP-Complete
David Evans CS200: Computer Science University of Virginia Computer Science Class 38: Intractable Problems (Smiley Puzzles.
1 The Limits of Computation Intractable and Non-computable functions.
NP-Completeness Lecture for CS 302. Traveling Salesperson Problem You have to visit n cities You want to make the shortest trip How could you do this?
CPE702 Complexity Classes Pruet Boonma Department of Computer Engineering Chiang Mai University Based on Material by Jenny Walter.
David Evans CS150: Computer Science University of Virginia Computer Science Lecture 18: The Story So Far.
CSE332: Data Abstractions Lecture 27: A Few Words on NP Dan Grossman Spring 2010.
NP-complete and NP-hard problems Transitivity of polynomial-time many-one reductions Definition of complexity class NP –Nondeterministic computation –Problems.
1 CSE 417: Algorithms and Computational Complexity Winter 2001 Lecture 21 Instructor: Paul Beame.
The Theory of NP-Completeness
NP-Complete Problems Problems in Computer Science are classified into
NP-complete and NP-hard problems
Analysis of Algorithms CS 477/677
NP-Complete Problems CSC 331: Algorithm Analysis NP-Complete Problems.
Scott Perryman Jordan Williams.  NP-completeness is a class of unsolved decision problems in Computer Science.  A decision problem is a YES or NO answer.
1 The Theory of NP-Completeness 2012/11/6 P: the class of problems which can be solved by a deterministic polynomial algorithm. NP : the class of decision.
David Evans Class 13: Quicksort, Problems and Procedures CS150: Computer Science University of Virginia Computer Science.
Complexity Classes (Ch. 34) The class P: class of problems that can be solved in time that is polynomial in the size of the input, n. if input size is.
David Evans Turing Machines, Busy Beavers, and Big Questions about Computing.
FACULTY OF ENGINEERING & INFORMATION TECHNOLOGIES P, NP, and Complexity Six fundamental facts One rule of thumb Three fundamental notions One fundamental.
Tonga Institute of Higher Education Design and Analysis of Algorithms IT 254 Lecture 8: Complexity Theory.
David Evans Curing Cancer with Your Cell Phone: Why all Sciences are Becoming Computing Sciences.
CSE 326: Data Structures NP Completeness Ben Lerner Summer 2007.
P and NP. Computational Complexity Recall from our sorting examples at the start of class that we could prove that any sort would have to do at least.
Cs3102: Theory of Computation Class 24: NP-Completeness Spring 2010 University of Virginia David Evans.
David Evans CS588: Security and Privacy University of Virginia Computer Science Lecture 15: Complexity Notes This is selected.
CSC 413/513: Intro to Algorithms NP Completeness.
CSC 172 P, NP, Etc. “Computer Science is a science of abstraction – creating the right model for thinking about a problem and devising the appropriate.
David Evans CS200: Computer Science University of Virginia Computer Science Class 25: Computability Halting Problems Hockey.
Week 10Complexity of Algorithms1 Hard Computational Problems Some computational problems are hard Despite a numerous attempts we do not know any efficient.
NP-COMPLETENESS PRESENTED BY TUSHAR KUMAR J. RITESH BAGGA.
CSCI 3160 Design and Analysis of Algorithms Tutorial 10 Chengyu Lin.
David Evans CS150: Computer Science University of Virginia Computer Science Lecture 10: Puzzling Pegboards.
CSE373: Data Structures & Algorithms Lecture 22: The P vs. NP question, NP-Completeness Lauren Milne Summer 2015.
Erdal Kose CC30.10 These slides are based of Prof. N. Yanofsky Lecture notes.
NP-COMPLETE PROBLEMS. Admin  Two more assignments…  No office hours on tomorrow.
NP-Complete problems.
NP-complete Problems Prof. Sin-Min Lee Department of Computer Science.
CPS What is Computer Science? What is it that distinguishes it from the separate subjects with which it is related? What is the linking thread.
CS 3343: Analysis of Algorithms Lecture 25: P and NP Some slides courtesy of Carola Wenk.
CSE 589 Part V One of the symptoms of an approaching nervous breakdown is the belief that one’s work is terribly important. Bertrand Russell.
Complexity & Computability. Limitations of computer science  Major reasons useful calculations cannot be done:  execution time of program is too long.
Fundamentals of Informatics Lecture 14 Intractability and NP-completeness Bas Luttik.
“One ring to rule them all” Analogy (sort of) Lord of The Rings Computational Complexity “One problem to solve them all” “my preciousss…”
David Evans CS200: Computer Science University of Virginia Computer Science Lecture 15: Intractable Problems (Smiley.
CS6045: Advanced Algorithms NP Completeness. NP-Completeness Some problems are intractable: as they grow large, we are unable to solve them in reasonable.
David Evans Class 15: P vs. NP (Smiley Puzzles and Curing Cancer) CS150: Computer Science University of Virginia Computer.
Chapter 11 Introduction to Computational Complexity Copyright © 2011 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1.
CS216: Program and Data Representation University of Virginia Computer Science Spring 2006 David Evans Lecture 8: Crash Course in Computational Complexity.
CSE 421 Algorithms Richard Anderson Lecture 27 NP-Completeness Proofs.
David Evans CS200: Computer Science University of Virginia Computer Science Lecture 14: P = NP?
Pancakes, Puzzles, and Polynomials: Cracking the Cracker Barrel Game Christopher Frost Michael Peck.
1 Computability Tractable, Intractable and Non-computable functions.
1 1. Which of these sequences correspond to Hamilton cycles in the graph? (a) (b) (c) (d) (e)
David Evans CS200: Computer Science University of Virginia Computer Science Lecture 23: Intractable Problems (Smiley Puzzles.
CS 154 Formal Languages and Computability May 10 Class Meeting Department of Computer Science San Jose State University Spring 2016 Instructor: Ron Mak.
The NP class. NP-completeness Lecture2. The NP-class The NP class is a class that contains all the problems that can be decided by a Non-Deterministic.
Construction We constructed the following graph: This graph has several nice properties: Diameter Two Graph Pebbling Tim Lewis 1, Dan Simpson 1, Sam Taggart.
CSE 332: NP Completeness, Part II Richard Anderson Spring 2016.
David Evans Lecture 41: P = NP? I will have extra office hours after class today (1-3pm). To be eligible to present Monday,
Lecture 22 Complexity and Reductions
Class 14: Intractable Problems CS150: Computer Science
Lecture 22: P = NP? CS200: Computer Science University of Virginia
Class 24: Computability Halting Problems Hockey Team Logo
NP-Completeness Lecture for CS 302.
Lecture 23: Computability CS200: Computer Science
Lecture 22 Complexity and Reductions
Presentation transcript:

David Evans Class 16: NP-Completeness / The Story so Far CS150: Computer Science University of Virginia Computer Science

2 CS150 Fall 2005: Lecture 16: NP Completeness Menu 3SAT Complexity class NP-Complete The Story so Far Some NP-Complete Problems

3 CS150 Fall 2005: Lecture 16: NP Completeness Problem Classes if P  NP: P NP Sorting:  (n log n) Simulating Universe: O(n 3 ) Smileys: O(n!) and  (n) Find Best:  (n) (n)(n) How many problems are in the  (n) class? How many problems are in P but not in the  (n) class? How many problems are in NP but not in P? infinite

4 CS150 Fall 2005: Lecture 16: NP Completeness Problem Classes if P = NP: P Sorting:  (n log n) Simulating Universe: O(n 3 ) Smileys:  (n k ) Find Best:  (n) (n)(n) How many problems are in the  (n) class? How many problems are in P but not in the  (n) class? How many problems are in NP but not in P? infinite 0

5 CS150 Fall 2005: Lecture 16: NP Completeness The 3SAT Problem Input: a sentence in propositional grammar, where each clause is a disjunction of 3 names which may be negated. Output: Either a mapping from names to values that satisfies the input sentence or no way (meaning there is no possible assignment that satisfies the input sentence)

6 CS150 Fall 2005: Lecture 16: NP Completeness 3SAT Example 3SAT ( (a  b   c)  (  a   b  d)  (  a  b   d)  (b   c  d ) )  { a: true, b: false, c: false, d: false } Sentence ::= Clause Clause ::= Clause 1  Clause 2 (or) Clause ::= Clause 1  Clause 2 (and) Clause ::=  Clause (not) Clause ::= ( Clause ) Clause ::= Name

7 CS150 Fall 2005: Lecture 16: NP Completeness 3SAT  Smiley Like 3/stone/apple/tower puzzle, we can convert every 3SAT problem into a Smiley Puzzle problem! Transformation is more complicated, but still polynomial time. So, if we have a fast (P) solution to Smiley Puzzle, we have a fast solution to 3SAT also!

8 CS150 Fall 2005: Lecture 16: NP Completeness NP Complete Cook and Levin proved that 3SAT was NP- Complete (1971) (Take CS660 to see how) A problem is NP-complete if it is as hard as the hardest problem in NP If 3SAT can be transformed into a different problem in polynomial time, than that problem must also be NP-complete. Either all NP-complete problems are tractable (in P) or none of them are!

9 CS150 Fall 2005: Lecture 16: NP Completeness Problem Classes if P  NP: P Sorting:  (n log n) Simulating Universe: O(n 3 ) Smileys Find Best:  (n) (n)(n) How many problems are in the  (n) class? How many problems are in P but not in the  (n) class? How many problems are in NP but not in P? infinite NP 3SAT NP-Complete Note the NP- Complete class is a ring – others are circles

10 CS150 Fall 2005: Lecture 16: NP Completeness Quiz Answers What would we need to do to prove a problem is O (n 4 ) ? What would we need to do to prove a problem is Ω (n 4 ) ? Find a procedure that solves the problem that is Ο(n 4 ). Prove that there is no procedure that solves the problem that is faster than  (n 4 ).

11 CS150 Fall 2005: Lecture 16: NP Completeness Quiz Responses: What is Computer Science? Remembered (or almost remembered first class): Study of "how to" knowledge, or whatever the fancy name for that is, The imperative study of procedures and language (I'm trying to remember what that definition was on the first day), "How to" do things; instead of declarative statements, talk about how to do things, I know we hade a specific definition in the beginning of the year but I forget it…I would say that computer science is a science/study of methods of manipulating data and information, the study of imperative knowledge; It doesn't need to have a computer and it's not a science, it doesn't deal with real things, instead numbers and data manipulations and problem solving; a liberal art, an innovative perspective on information; Study of imperative knowledge. Study of different types of problems and how to solve them. It's more of a liberal arts major than engineering.; liberal art! Learning about languages.; CS is not computer engineering, and its not science. Nevertheless, CS used sciences to prove computer problems.

12 CS150 Fall 2005: Lecture 16: NP Completeness Quiz Responses: What is Computer Science? Problem solving (logic, language): A way of thinking about computers and programs. A systematic way of creating and understanding how programs work, thinking differently, logically to how the computer language functions, It seems to be to theorize on how to systematically solve problems in a functional language, the study of logic and programs that can be understood by computers; Study of logics and way to solve problems; The study of using systems and algorithms to solve problems.; study of languages used to create intelligent computer procedures to solve usually huge or complex problems involving data ?!; the science of computers? Solving problems with computers; The study and use of languages to improve technology and program computers; CS is the art of getting a computer to do what you want through a common language.

13 CS150 Fall 2005: Lecture 16: NP Completeness Quiz Responses: What is Computer Science? Amusing: Computer Science is a great way to find new world. The bane of my existence.

14 CS150 Fall 2005: Lecture 16: NP Completeness Computer Science (Expanded) Definition from Class 1: –Study of information processes How to describe information processes by defining procedures How to predict properties about information processes How to elegantly and efficiently implement information processes in hardware and software What have we spent most of our time on so far?

15 CS150 Fall 2005: Lecture 16: NP Completeness Where we’ve been, Where we’re going

16 CS150 Fall 2005: Lecture 16: NP Completeness Computer Science: CS150 so far How to describe information processes by defining procedures –Programming with procedures, lists, recursion –Class 2, 4, 5, 6, 7, 8, 9, 10, 11, 12 How to predict properties about information processes –Measuring work, , Ο, Ω, complexity classes –Class 9, 10, 11, 12, 13, 14, 15, 16 How to elegantly and efficiently implement information processes in hardware and software –Class 3 (rules of evaluation)

17 CS150 Fall 2005: Lecture 16: NP Completeness CS150 upcoming How to describe information processes by defining procedures –Programming with mutation, objects, databases, networks How to predict properties about information processes –What are we counting when we measure work? –Are there problems which can’t be solved by procedures? How to elegantly and efficiently implement information processes in hardware and software –How to implement a Scheme interpreter –Not much in CS150 on hardware (see CS230 and CS333)

18 CS150 Fall 2005: Lecture 16: NP Completeness Famous Computer Scientists Ada – first computer scientist –She’s in the course name! Grace Hopper – first compiler –First “bug”, Navy ship, David Letterman nano John Backus – BNF, Fortran –UVa dropout Tony Hoare – Quicksort

19 CS150 Fall 2005: Lecture 16: NP Completeness Famous Computer Scientists Bill Gates (?) –Didn’t invent Windows interface, word processor, PC, etc. (mostly invented by Doug Englebart and XEROX Parc) –Business notion that people would pay for software for PCs –Implemented a BASIC interpreter (but didn’t invent BASIC)

20 CS150 Fall 2005: Lecture 16: NP Completeness NP Complete Problems

21 CS150 Fall 2005: Lecture 16: NP Completeness NP-Complete Problems Easy way to solve by trying all possible guesses If given the “yes” answer, quick (in P) way to check if it is right –Solution to puzzle (see if it looks right) –Assignments of values to names (evaluate logical proposition in linear time) If given the “no” answer, no quick way to check if it is right –No solution (can’t tell there isn’t one) –No way (can’t tell there isn’t one)

22 CS150 Fall 2005: Lecture 16: NP Completeness Traveling Salesperson Problem –Input: a graph of cities and roads with distance connecting them and a minimum total distant –Output: either a path that visits each with a cost less than the minimum, or “no”. If given a path, easy to check if it visits every city with less than minimum distance traveled

23 CS150 Fall 2005: Lecture 16: NP Completeness Graph (Map) Coloring Problem –Input: a graph of nodes with edges connecting them and a minimum number of colors –Output: either a coloring of the nodes such that no connected nodes have the same color, or “no”. If given a coloring, easy to check if it no connected nodes have the same color, and the number of colors used.

24 CS150 Fall 2005: Lecture 16: NP Completeness Minesweeper Consistency Problem –Input: a position of n squares in the game Minesweeper –Output: either a assignment of bombs to squares, or “no”. If given a bomb assignment, easy to check if it is consistent.

25 CS150 Fall 2005: Lecture 16: NP Completeness Pegboard Problem

26 CS150 Fall 2005: Lecture 16: NP Completeness Pegboard Problem - Input: a configuration of n pegs on a cracker barrel style pegboard - Output: if there is a sequence of jumps that leaves a single peg, output that sequence of jumps. Otherwise, output false. If given the sequence of jumps, easy (O( n )) to check it is correct. If not, hard to know if there is a solution.

27 CS150 Fall 2005: Lecture 16: NP Completeness Drug Discovery Problem –Input: a set of proteins, a desired 3D shape –Output: a sequence of proteins that produces the shape (or impossible) Note: US Drug sales = $200B/year If given a sequence, easy (not really) to check if sequence has the right shape. Caffeine

28 CS150 Fall 2005: Lecture 16: NP Completeness Is it ever useful to be confident that a problem is hard? Hint: PS4

29 CS150 Fall 2005: Lecture 16: NP Completeness Charge AC’s exam review is tonight at 7pm Friday: –Exam 1 out (will be posted on web also) –How Lorenz was really broken