SlideShare a Scribd company logo
1 of 21
Download to read offline
P versus NP
The greatest unsolved problem in Computer Science
And perhaps all in Mathematics!
Rituraj Joshi
CSE ‘16
What is an efficient algorithm?
Polynomial times -
➢ O(n)
➢ O(n2
)
➢ O(n10
)
Logarithmic running times-
➢ O(log n)
➢ O(n log n)
Non-Polynomial time -
➢ O(2n
)
➢ O(n!)
The P Class (problems that have fast solutions)
The general class of problems for which some algorithm can provide an answer in
polynomial time.
● Searching (Binary, Linear)
● Sorting (Merge, Insertion, Quick, etc)
● Greatest Common Divisor
● Multiplication
● Shortest Paths (Dijkstra’s, Bellman-Ford, etc)
● Minimum cost spanning trees
● Rubik’s Cube
The NP Class (no fast solutions known)
The class of questions for which an answer can be verified in polynomial time is called
NP, which stands for non-deterministic polynomial time but there is no known way to
find an answer quickly.
● Integer Factorization
● Sudoku
● Traveling Salesman Problem
● Graph Coloring
● 3 - SAT
● Vertex Cover
● Subset Sum
● Independent Set
Sudoku
Sudoku
O (nm
)
n = no of possibilities in each
cell (i.e. 9)
m = no of unfilled cells
What it means ?
Are the problems that are easy to check, also easy to solve?
All problems in P, are also in NP.
If I can solve a problem quickly, I can verify the solution
quickly by just solving the problem quickly.
Factorization
● A teacher assigns homework assignment:
○ Factorize a large number that is the product of two primes
● Student: Given N, find p,q such that pq = N
○ Generate a solution
● Teacher: Given a student’s solution p,q, verify that pq = N
○ Check a solution
Factorization
● For small values of N:
○ E.g. - 63, we have 3*21 = 63
● For large values like :
● How will you solve ?
● No efficient solution known
Easy to check but difficult to find p,q such that pq = N for large values of N
Boolean Satisfiability
● Boolean variables x, y, z, ....
● 3 - SAT - each clause has at most 3 literals
● A clause is a boolean expression having variables connected by or of the form
( x || !y || z || …. || w )
● Formula - clauses connected by and in between
C1 & C2 & … & Cn
( x || y || z ) & ( x || !y ) & ( y || !z ) & ( !x || !y || !z )
● Find if an assignment of values either true or false to variables is possible such
that the whole expression evaluates to true or report no such assignment
exists
( x || y || z ) & ( x || !y ) & ( y || !z ) & ( !x || !y || !z )
● x = True, y= True, z = False makes this true
( x || y || z ) & ( x || !y ) & ( y || !z ) & ( z || !x ) & ( !x || !y || !z )
● Now there is no satisfying assignment
● Generating a solution
○ Try each possible assignment x, y, z, …
○ N variables - 2N
assignments
● Is there a better algorithm? Not known
● Checking is easy!
Boolean Satisfiability
Independent Set
● Vertices u, v are independent if there is no edge (u, v)
● U is an independent set if each pair (u,v) in U is independent
● Constitute a neutral committee where none of the members know each other
● Find the largest independent set in a given graph
● Checking version: Is there an independent set of size K?
● Again, checking is easy!
Vertex Cover
● Node u covers every edge (u, v) incident on u
● U is a vertex cover if each edge in the graph is covered by some vertex in U
● Position surveillance cameras at intersections to watch all roads
● Find the smallest vertex cover in a given graph
● Checking version: Is there a vertex cover of size K ?
Connecting independent set and vertex cover
● U is an independent set of size K iff V-U is a vertex cover of size N-K
● =>
● Every edge (u, v) has at most one endpoint in U, so at least one endpoint in V-U
● <=
● For any edge (u, v), at least one endpoint in V-U, so no edges (u,v) within U
Traveling Salesman Problem
● A network of cities with distances between each pair
● A complete graph G = (V, E) with edge weights
● Find the shortest tour that visits each city exactly once
● Simple cycle x,y,z,...,x visiting all vertices, of minimum cost (Hamiltonian Cycle)
● Given a graph G and a proposed solution S we can
● Verify that S is a cycle
● Compute its cost
● How to check that S is the least cost cycle
Reductions
A reduction is a polynomial time algorithm that converts solution of one problem to
solution of another problem
● Independent set and vertex cover reduce to each other
● Recall: if A reduces to B and A is intractable, so is B
● Many pairs of checkable problems are inter-reducible
● All “equally” hard
Reductions
What if P = NP?
It is said that world would profoundly be a very different place than it is now.
❏ Problems like protein folding will help us cure cancer
❏ RSA Encryption would be easy to crack (based on factoring)
❏ Artificial Intelligent systems would make huge leaps overnight
❏ Transportation scheduled optimally: people and goods moved around quickly and
cheaper
❏ Automatically generate mathematical proofs?
How to prove it?
● To prove P = NP
○ Give a polynomial time algorithm to any NP complete problem
● To prove P !=NP
○ Prove that there exists NO ALGORITHM to solve some NP problem in polynomial
time
Not an easy task!
NP Completeness
● SAT is said to be complete for NP
○ It belongs to NP
○ Every problem in NP reduces to it (Cook-Levin Theorem)
● If you can solve SAT, you can solve any NP problem
● Original proof is by recoding computations of Turing Machines
NP Hard
● Not sure if it belongs to NP
● Because checking algorithm is not there
Thank you
P versus NP

More Related Content

Similar to P versus NP

Time and space complexity
Time and space complexityTime and space complexity
Time and space complexity
Ankit Katiyar
 

Similar to P versus NP (20)

DAA.pdf
DAA.pdfDAA.pdf
DAA.pdf
 
DAA.pdf
DAA.pdfDAA.pdf
DAA.pdf
 
Teori pnp
Teori pnpTeori pnp
Teori pnp
 
UNIT-V.ppt
UNIT-V.pptUNIT-V.ppt
UNIT-V.ppt
 
NP-Completeness-myppt.pptx
NP-Completeness-myppt.pptxNP-Completeness-myppt.pptx
NP-Completeness-myppt.pptx
 
CSE680-17NP-Complete.pptx
CSE680-17NP-Complete.pptxCSE680-17NP-Complete.pptx
CSE680-17NP-Complete.pptx
 
Np completeness h4
Np completeness  h4Np completeness  h4
Np completeness h4
 
NP completeness
NP completenessNP completeness
NP completeness
 
Lecture8
Lecture8Lecture8
Lecture8
 
A comprehensive view on P vs NP
A comprehensive view on P vs NPA comprehensive view on P vs NP
A comprehensive view on P vs NP
 
Np completeness
Np completenessNp completeness
Np completeness
 
Time and space complexity
Time and space complexityTime and space complexity
Time and space complexity
 
Logic agent
Logic agentLogic agent
Logic agent
 
9. chapter 8 np hard and np complete problems
9. chapter 8   np hard and np complete problems9. chapter 8   np hard and np complete problems
9. chapter 8 np hard and np complete problems
 
class23.ppt
class23.pptclass23.ppt
class23.ppt
 
Asymptotics 140510003721-phpapp02
Asymptotics 140510003721-phpapp02Asymptotics 140510003721-phpapp02
Asymptotics 140510003721-phpapp02
 
Np complete
Np completeNp complete
Np complete
 
NP-Completeness - II
NP-Completeness - IINP-Completeness - II
NP-Completeness - II
 
lect5-1.ppt
lect5-1.pptlect5-1.ppt
lect5-1.ppt
 
Stochastic Process Exam Help
Stochastic Process Exam HelpStochastic Process Exam Help
Stochastic Process Exam Help
 

Recently uploaded

Final DBMS Manual (2).pdf final lab manual
Final DBMS Manual (2).pdf final lab manualFinal DBMS Manual (2).pdf final lab manual
Final DBMS Manual (2).pdf final lab manual
BalamuruganV28
 
Artificial intelligence presentation2-171219131633.pdf
Artificial intelligence presentation2-171219131633.pdfArtificial intelligence presentation2-171219131633.pdf
Artificial intelligence presentation2-171219131633.pdf
Kira Dess
 
21P35A0312 Internship eccccccReport.docx
21P35A0312 Internship eccccccReport.docx21P35A0312 Internship eccccccReport.docx
21P35A0312 Internship eccccccReport.docx
rahulmanepalli02
 

Recently uploaded (20)

Seismic Hazard Assessment Software in Python by Prof. Dr. Costas Sachpazis
Seismic Hazard Assessment Software in Python by Prof. Dr. Costas SachpazisSeismic Hazard Assessment Software in Python by Prof. Dr. Costas Sachpazis
Seismic Hazard Assessment Software in Python by Prof. Dr. Costas Sachpazis
 
NO1 Best Powerful Vashikaran Specialist Baba Vashikaran Specialist For Love V...
NO1 Best Powerful Vashikaran Specialist Baba Vashikaran Specialist For Love V...NO1 Best Powerful Vashikaran Specialist Baba Vashikaran Specialist For Love V...
NO1 Best Powerful Vashikaran Specialist Baba Vashikaran Specialist For Love V...
 
Maximizing Incident Investigation Efficacy in Oil & Gas: Techniques and Tools
Maximizing Incident Investigation Efficacy in Oil & Gas: Techniques and ToolsMaximizing Incident Investigation Efficacy in Oil & Gas: Techniques and Tools
Maximizing Incident Investigation Efficacy in Oil & Gas: Techniques and Tools
 
CLOUD COMPUTING SERVICES - Cloud Reference Modal
CLOUD COMPUTING SERVICES - Cloud Reference ModalCLOUD COMPUTING SERVICES - Cloud Reference Modal
CLOUD COMPUTING SERVICES - Cloud Reference Modal
 
Interfacing Analog to Digital Data Converters ee3404.pdf
Interfacing Analog to Digital Data Converters ee3404.pdfInterfacing Analog to Digital Data Converters ee3404.pdf
Interfacing Analog to Digital Data Converters ee3404.pdf
 
Software Engineering Practical File Front Pages.pdf
Software Engineering Practical File Front Pages.pdfSoftware Engineering Practical File Front Pages.pdf
Software Engineering Practical File Front Pages.pdf
 
UNIT 4 PTRP final Convergence in probability.pptx
UNIT 4 PTRP final Convergence in probability.pptxUNIT 4 PTRP final Convergence in probability.pptx
UNIT 4 PTRP final Convergence in probability.pptx
 
Filters for Electromagnetic Compatibility Applications
Filters for Electromagnetic Compatibility ApplicationsFilters for Electromagnetic Compatibility Applications
Filters for Electromagnetic Compatibility Applications
 
The Entity-Relationship Model(ER Diagram).pptx
The Entity-Relationship Model(ER Diagram).pptxThe Entity-Relationship Model(ER Diagram).pptx
The Entity-Relationship Model(ER Diagram).pptx
 
5G and 6G refer to generations of mobile network technology, each representin...
5G and 6G refer to generations of mobile network technology, each representin...5G and 6G refer to generations of mobile network technology, each representin...
5G and 6G refer to generations of mobile network technology, each representin...
 
Final DBMS Manual (2).pdf final lab manual
Final DBMS Manual (2).pdf final lab manualFinal DBMS Manual (2).pdf final lab manual
Final DBMS Manual (2).pdf final lab manual
 
analog-vs-digital-communication (concept of analog and digital).pptx
analog-vs-digital-communication (concept of analog and digital).pptxanalog-vs-digital-communication (concept of analog and digital).pptx
analog-vs-digital-communication (concept of analog and digital).pptx
 
What is Coordinate Measuring Machine? CMM Types, Features, Functions
What is Coordinate Measuring Machine? CMM Types, Features, FunctionsWhat is Coordinate Measuring Machine? CMM Types, Features, Functions
What is Coordinate Measuring Machine? CMM Types, Features, Functions
 
Raashid final report on Embedded Systems
Raashid final report on Embedded SystemsRaashid final report on Embedded Systems
Raashid final report on Embedded Systems
 
Worksharing and 3D Modeling with Revit.pptx
Worksharing and 3D Modeling with Revit.pptxWorksharing and 3D Modeling with Revit.pptx
Worksharing and 3D Modeling with Revit.pptx
 
Artificial intelligence presentation2-171219131633.pdf
Artificial intelligence presentation2-171219131633.pdfArtificial intelligence presentation2-171219131633.pdf
Artificial intelligence presentation2-171219131633.pdf
 
21P35A0312 Internship eccccccReport.docx
21P35A0312 Internship eccccccReport.docx21P35A0312 Internship eccccccReport.docx
21P35A0312 Internship eccccccReport.docx
 
Research Methodolgy & Intellectual Property Rights Series 1
Research Methodolgy & Intellectual Property Rights Series 1Research Methodolgy & Intellectual Property Rights Series 1
Research Methodolgy & Intellectual Property Rights Series 1
 
Independent Solar-Powered Electric Vehicle Charging Station
Independent Solar-Powered Electric Vehicle Charging StationIndependent Solar-Powered Electric Vehicle Charging Station
Independent Solar-Powered Electric Vehicle Charging Station
 
21scheme vtu syllabus of visveraya technological university
21scheme vtu syllabus of visveraya technological university21scheme vtu syllabus of visveraya technological university
21scheme vtu syllabus of visveraya technological university
 

P versus NP

  • 1. P versus NP The greatest unsolved problem in Computer Science And perhaps all in Mathematics! Rituraj Joshi CSE ‘16
  • 2. What is an efficient algorithm? Polynomial times - ➢ O(n) ➢ O(n2 ) ➢ O(n10 ) Logarithmic running times- ➢ O(log n) ➢ O(n log n) Non-Polynomial time - ➢ O(2n ) ➢ O(n!)
  • 3. The P Class (problems that have fast solutions) The general class of problems for which some algorithm can provide an answer in polynomial time. ● Searching (Binary, Linear) ● Sorting (Merge, Insertion, Quick, etc) ● Greatest Common Divisor ● Multiplication ● Shortest Paths (Dijkstra’s, Bellman-Ford, etc) ● Minimum cost spanning trees ● Rubik’s Cube
  • 4. The NP Class (no fast solutions known) The class of questions for which an answer can be verified in polynomial time is called NP, which stands for non-deterministic polynomial time but there is no known way to find an answer quickly. ● Integer Factorization ● Sudoku ● Traveling Salesman Problem ● Graph Coloring ● 3 - SAT ● Vertex Cover ● Subset Sum ● Independent Set
  • 6. Sudoku O (nm ) n = no of possibilities in each cell (i.e. 9) m = no of unfilled cells
  • 7. What it means ? Are the problems that are easy to check, also easy to solve? All problems in P, are also in NP. If I can solve a problem quickly, I can verify the solution quickly by just solving the problem quickly.
  • 8. Factorization ● A teacher assigns homework assignment: ○ Factorize a large number that is the product of two primes ● Student: Given N, find p,q such that pq = N ○ Generate a solution ● Teacher: Given a student’s solution p,q, verify that pq = N ○ Check a solution
  • 9. Factorization ● For small values of N: ○ E.g. - 63, we have 3*21 = 63 ● For large values like : ● How will you solve ? ● No efficient solution known Easy to check but difficult to find p,q such that pq = N for large values of N
  • 10. Boolean Satisfiability ● Boolean variables x, y, z, .... ● 3 - SAT - each clause has at most 3 literals ● A clause is a boolean expression having variables connected by or of the form ( x || !y || z || …. || w ) ● Formula - clauses connected by and in between C1 & C2 & … & Cn ( x || y || z ) & ( x || !y ) & ( y || !z ) & ( !x || !y || !z ) ● Find if an assignment of values either true or false to variables is possible such that the whole expression evaluates to true or report no such assignment exists
  • 11. ( x || y || z ) & ( x || !y ) & ( y || !z ) & ( !x || !y || !z ) ● x = True, y= True, z = False makes this true ( x || y || z ) & ( x || !y ) & ( y || !z ) & ( z || !x ) & ( !x || !y || !z ) ● Now there is no satisfying assignment ● Generating a solution ○ Try each possible assignment x, y, z, … ○ N variables - 2N assignments ● Is there a better algorithm? Not known ● Checking is easy! Boolean Satisfiability
  • 12. Independent Set ● Vertices u, v are independent if there is no edge (u, v) ● U is an independent set if each pair (u,v) in U is independent ● Constitute a neutral committee where none of the members know each other ● Find the largest independent set in a given graph ● Checking version: Is there an independent set of size K? ● Again, checking is easy!
  • 13. Vertex Cover ● Node u covers every edge (u, v) incident on u ● U is a vertex cover if each edge in the graph is covered by some vertex in U ● Position surveillance cameras at intersections to watch all roads ● Find the smallest vertex cover in a given graph ● Checking version: Is there a vertex cover of size K ?
  • 14. Connecting independent set and vertex cover ● U is an independent set of size K iff V-U is a vertex cover of size N-K ● => ● Every edge (u, v) has at most one endpoint in U, so at least one endpoint in V-U ● <= ● For any edge (u, v), at least one endpoint in V-U, so no edges (u,v) within U
  • 15. Traveling Salesman Problem ● A network of cities with distances between each pair ● A complete graph G = (V, E) with edge weights ● Find the shortest tour that visits each city exactly once ● Simple cycle x,y,z,...,x visiting all vertices, of minimum cost (Hamiltonian Cycle) ● Given a graph G and a proposed solution S we can ● Verify that S is a cycle ● Compute its cost ● How to check that S is the least cost cycle
  • 16. Reductions A reduction is a polynomial time algorithm that converts solution of one problem to solution of another problem ● Independent set and vertex cover reduce to each other ● Recall: if A reduces to B and A is intractable, so is B ● Many pairs of checkable problems are inter-reducible ● All “equally” hard
  • 18. What if P = NP? It is said that world would profoundly be a very different place than it is now. ❏ Problems like protein folding will help us cure cancer ❏ RSA Encryption would be easy to crack (based on factoring) ❏ Artificial Intelligent systems would make huge leaps overnight ❏ Transportation scheduled optimally: people and goods moved around quickly and cheaper ❏ Automatically generate mathematical proofs?
  • 19. How to prove it? ● To prove P = NP ○ Give a polynomial time algorithm to any NP complete problem ● To prove P !=NP ○ Prove that there exists NO ALGORITHM to solve some NP problem in polynomial time Not an easy task!
  • 20. NP Completeness ● SAT is said to be complete for NP ○ It belongs to NP ○ Every problem in NP reduces to it (Cook-Levin Theorem) ● If you can solve SAT, you can solve any NP problem ● Original proof is by recoding computations of Turing Machines NP Hard ● Not sure if it belongs to NP ● Because checking algorithm is not there