Computability Heap exercise. The class P. The class NP. Verifiers. Homework: Review RELPRIME proof. Find examples of problems in NP.

Slides:



Advertisements
Similar presentations
Part VI NP-Hardness. Lecture 23 Whats NP? Hard Problems.
Advertisements

NP-Complete Problems CIT 596, Spring Problems that Cross the Line What if a problem has: o An exponential upper bound o A polynomial lower bound.
Complexity Classes: P and NP
Time Complexity P vs NP.
The Big Picture Chapter 3. We want to examine a given computational problem and see how difficult it is. Then we need to compare problems Problems appear.
The class NP Section 7.3 Giorgi Japaridze Theory of Computability.
Lecture 21 Nondeterministic Polynomial time, and the class NP FIT2014 Theory of Computation Monash University Faculty of Information Technology Slides.
Complexity 12-1 Complexity Andrei Bulatov Non-Deterministic Space.
Complexity 15-1 Complexity Andrei Bulatov Hierarchy Theorem.
Computability and Complexity 13-1 Computability and Complexity Andrei Bulatov The Class NP.
P and NP Sipser (pages ). CS 311 Fall Polynomial time P = ∪ k TIME(n k ) … P = ∪ k TIME(n k ) … TIME(n 3 ) TIME(n 2 ) TIME(n)
Tractable and intractable problems for parallel computers
1 CSE 417: Algorithms and Computational Complexity Winter 2001 Lecture 21 Instructor: Paul Beame.
The Theory of NP-Completeness
Analysis of Algorithms CS 477/677
Applied Computer Science II Chapter 7: Time Complexity Prof. Dr. Luc De Raedt Institut für Informatik Albert-Ludwigs Universität Freiburg Germany.
CS 310 – Fall 2006 Pacific University CS310 P vs NP the steel cage death match Section 7.2 November 29, 2006.
Chapter 11: Limitations of Algorithmic Power
Fall 2004COMP 3351 Time Complexity We use a multitape Turing machine We count the number of steps until a string is accepted We use the O(k) notation.
MCS312: NP-completeness and Approximation Algorithms
Computational Complexity Polynomial time O(n k ) input size n, k constant Tractable problems solvable in polynomial time(Opposite Intractable) Ex: sorting,
CMPS 3223 Theory of Computation Automata, Computability, & Complexity by Elaine Rich ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Slides provided.
Nattee Niparnan. Easy & Hard Problem What is “difficulty” of problem? Difficult for computer scientist to derive algorithm for the problem? Difficult.
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.
חישוביות וסיבוכיות Computability and Complexity Lecture 7 TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: A AAAA.
Approximation Algorithms Pages ADVANCED TOPICS IN COMPLEXITY THEORY.
Review Byron Gao. Overview Theory of computation: central areas: Automata, Computability, Complexity Computability: Is the problem solvable? –solvable.
1 Joe Meehean.  Log: binary search in sorted array  Linear: traverse a tree  Log-Linear: insert into a heap  Quadratic (N 2 ): your sort from P1 
CSE 326: Data Structures NP Completeness Ben Lerner Summer 2007.
Computer Language Theory
CSC 413/513: Intro to Algorithms NP Completeness.
The class P Section 7.2 CSC 4170 Theory of Computation.
CSCI 2670 Introduction to Theory of Computing November 29, 2005.
Complexity Non-determinism. NP complete problems. Does P=NP? Origami. Homework: continue on postings.
CSE 3813 Introduction to Formal Languages and Automata Chapter 14 An Introduction to Computational Complexity These class notes are based on material from.
Complexity 25-1 Complexity Andrei Bulatov Counting Problems.
CSCI 3160 Design and Analysis of Algorithms Tutorial 10 Chengyu Lin.
NP-Complete Problems. Running Time v.s. Input Size Concern with problems whose complexity may be described by exponential functions. Tractable problems.
1Computer Sciences Department. Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER Reference 3Computer Sciences Department.
Automata & Formal Languages, Feodor F. Dragan, Kent State University 1 CHAPTER 7 Time complexity Contents Measuring Complexity Big-O and small-o notation.
CSCI 2670 Introduction to Theory of Computing November 17, 2005.
Donghyun (David) Kim Department of Mathematics and Computer Science North Carolina Central University 1 Chapter 7 Time Complexity Some slides are in courtesy.
Chapter 11 Introduction to Computational Complexity Copyright © 2011 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1.
1 Time Complexity We use a multitape Turing machine We count the number of steps until a string is accepted We use the O(k) notation.
The Big Picture Chapter 3.
Lecture. Today Problem set 9 out (due next Thursday) Topics: –Complexity Theory –Optimization versus Decision Problems –P and NP –Efficient Verification.
COSC 3101A - Design and Analysis of Algorithms 14 NP-Completeness.
Prof. Busch - LSU1 Time Complexity. Prof. Busch - LSU2 Consider a deterministic Turing Machine which decides a language.
Computability Examples. Reducibility. NP completeness. Homework: Find other examples of NP complete problems.
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.
Theory of Computational Complexity TA : Junichi Teruyama Iwama lab. D3
Complexity, Decidability, Computability and other impossible questions Stephen Dolan, IMSA 2010.
The NP class. NP-completeness
CSE 105 theory of computation
CSC 4170 Theory of Computation The class P Section 7.2.
Part VI NP-Hardness.
Computability and Complexity
CSC 4170 Theory of Computation The class P Section 7.2.
Complexity 6-1 The Class P Complexity Andrei Bulatov.
CLASSES P AND NP.
Chapter 11 Limitations of Algorithm Power
NP-Complete Problems.
Theory of Computability
CS21 Decidability and Tractability
Time Complexity Classes
Instructor: Aaron Roth
CSE 105 theory of computation
Theory of Computability
Theory of Computability
Presentation transcript:

Computability Heap exercise. The class P. The class NP. Verifiers. Homework: Review RELPRIME proof. Find examples of problems in NP.

Heap sort Heap sort: –make whole set into a heap, starting at the top –Loop: remove root: swap with last member. Remove (don't think about this position any more). Then restore heap property by possibly pushing value down. We only need to fix up one of the two subtrees at each stage. mlhttp://nova.umuc.edu/~jarc/idsv/lesson3.ht ml

Formalities The Sipser text does everything in terms of Turing machines. We may talk more on some general model, such as encoding in a programming language

Multiple tape TM Let M be a multiple tape TM that takes t(n) time, t(n)>=n. Then M can be simulated by a single tape TM N taking at most O(t 2 (n)). Informal proof: Material on all the tapes must be bounded by t(n). 1) Use O(n) to set up single tape and put in markers for the k tapes. 2) Simulation of each step bounded by t(n) 3) So c* t(n) * t(n) is the bound.

Class P All languages that are decidable in polynomial time on a single tape, deterministic Turing machine.

Alternative definition Consider a standard programming language, an algorithm is in the class P if the running time for an input (size of input is n) is bounded by a polynomial p(n). All the sorts, searches, shuffles discussed so far are in P.

Practicality In practical terms, there is a big difference between algorithms O(log(n)),O(n), O(nlog(n)), O(n 2 ), etc. Say n = 1000, then what is ?? –O(log(n)) use 10 as the base –O(n) –O(nlog(n)) –O(n 2 ) –O(n 3 )

Answers O(log(n)) 3 O(n) 1000 O(nlog(n))3000 O(n 2 ) O(n 3 )

Terminology BUT bigger difference between polynomial and exponential –1000 versus (1 billion) versus (more than the number of atoms in the universe…) So polynomial time algorithms are called easy, tractable, practical and the exponential algorithms called hard, intractable, impractical. Note: these are all solvable. That is, there are deciders for the language accepting programs or programs that halt with an answer for the functions.

RELPRIME For two natural numbers, x and y, x and y are relatively prime if 1 is the largest number that is a factor of both. Neither may be prime, but relatively prime means they don't share any factors. Note: if each is prime, then they are relatively prime.

Examples 2 and 3 Yes! easy, each is prime 4 and 9 Yes, try the factors 2 and and 64 No! 2 is a factor. Two even number are not relatively prime. 75 and 14 Yes, factors 3 & 5 versus 2 & 7 Now, each of you supply 1 pair that is relatively prime and 1 that is not.

How to determine Relprime? Brute force (which is what I did): –determine factors of each and compare. –this is exponential… Alternative: –Use Euclidean Algorithm for greatest common divisor of x & y. –If gcd is 1, return yes (true) else return false.

function gcd(x,y) { do { w = x % y; // x mod y x = y; y = w; // swap x and y } until (y == 0) return x; }

Example x = 9, y = 4 –w = 9 % 4 ; // w = 1 –x = 9, y = 1; –w = 9 % 1; // w = 0 –x = 1, y = 0 –return 1 relatively prime!

Example x = 6, y = 9 w = 6 % 9; //w = 6 x = 9; y = 6 w = 9 % 6; // w = 3 x = 6; y = 3; w = 6 % 3; // w = 0 x = 3; y = 0 return 3 NOT relatively prime

Analysis After possibly the first stage, each stage cuts the value of x in half. Since values are swapped, each of x and y are halved every two times. So number of stages is proportional log(x) plus log(y). This is polynomial…Actually O(n) LOOK UP AND GIVE IMPROVED PROOF.

Non-deterministic algorithm Think of TM with multiple possibilities OR Using the programming language model, think of making guesses from a finite set of choices.

Example: Composites Composites = {x | x = pq where p, q >1} –is x not a prime? Factoring is difficult (more on this later) but given a number X, if you can produce a candidate set p and q, then it is easy to check if x = p * q.

Hamiltonian circuit Let G be a directed graph. A Hamiltonian circuit is a path using the edges of G that goes through each vertex exactly once. HAMPATH = { | there is a Hamiltonian path from s to t} –language definition. No good way (so far) to determine if there is such as path for any, that is, is in the language.

Verifier / checker Some problems have the feature that finding a solution may be difficult, but checking it may be easy / easier. That is, one way to do the problem may involve guessing (the algorithm may be exponential) …. but checking can be done relatively easily (polynomial).

Formal definition: verifier Given a language A, a verifier V is an algorithm such that A = {w | V accepts for some string c} The string c is the answer or certificate or proof that w is in A.

Verifiers A verifier for Composites multiplies the factors. A verifier for HAMPATH checks out the candidate path.

NP is the class of languages that have polynomial time verifiers. This would include all the languages that are decided in polynomial time plus some others.

Theorem A language is in NP if and only if it can be decided by a polynomial time Turing Machine –or, using a program model, a program that makes choices among a finite number of options at certain stages.

P = NP??? It is not known, and one of, if not the most important problems in theoretical computer science, whether or not P = NP. If true, this means that for each NP problem, there is a P algorithm. If false, this means that for some NP problems (more on this later), there is no P algorithm.

Homework Review RELPRIME algorithm and analysis and give [more] formal proof that it is polynomial. Find another problem that is NP. Read about P and NP.