Quantcast
Channel: Hacker News 50
Viewing all articles
Browse latest Browse all 9433

P versus NP Explained

$
0
0

Comments:"P versus NP Explained"

URL:http://www.danielmiessler.com/study/pvsnp/


If you spend time in the programming community you probably hear the term “P versus NP” rather frequently. Unfortunately, many with computer science degrees have a weak understanding of the concept—let alone those without any training on it.

So here it is, explained simply in a way you'll hopefully never forget.

P vs. NP P versus NP is the gap between being able to solve a difficult problem quickly and being able to verify the correctness of any given answer to that problem.

P and NP are two different kinds of problems. P problems are easy for computers to solve, and NP problems are easy for computers to check answers for, but extremely difficult for computers to solve.

All P problems are NP problems; that is, if it's easy for the computer to solve, it's easy to verify the solution. The P vs NP problem asks: within the class of NP problems, are there problems which are not P, that is, which are not easy for computers to solve?

The problem is that most real-world challenges are NP problems, not P problems. Let's look at a few examples:

  • A traveling salesman wants to visit 100 different cities by driving, starting and ending his trip at home. He has a limited supply of gasoline, so he can only drive a total of 10,000 kilometers. He wants to know if he can visit all of the cities without running out of gasoline.
  • A farmer wants to take 100 watermelons of different masses to the market. She needs to pack the watermelons into boxes. Each box can only hold 20 kilograms without breaking. The farmer needs to know if 10 boxes will be enough for her to carry all 100 watermelons to market.

All of these problems share a common characteristic that is the key to understanding the nature of P versus NP: In order to solve hard (NP) problems, you have to try all combinations.

So the question everyone's trying to answer is this: Is it possible to find an algorithm for the hard problems (NP problems) that is faster than checking every single possibility?

This is why the P versus NP problem is so interesting to people. If anyone were to solve it, it would potentially make very difficult problems very easy for computers to solve.

P vs. NP deals with the gap between computers being able to quickly solve problems vs. just being able to test proposed solutions for correctness. As such, the P vs. NP problem is the search for a way to solve problems that require the trying of millions, billions, or trillions of combinations without actually having to try each one. Solving this problem would have profound effects on computing, and therefore on our society.

[ 03.02.14: Cleaned up some of the explanation based on the possibility of confusion. ]

There is a class of NP problems that are NP-Complete, which means that if you solve them then you can use the same method to solve any other NP problem quickly. This is a highly simplified explanation designed to acquaint people with the concept. For a more complete exploration, check out the Wikipedia article or the numerous resources online.

If you’d like to connect or respond, please reach out via Twitter, using the comments below, or by email. Also consider subscribing to the site via RSS and checking out my other content.

Thank you for visiting.

Please enable JavaScript to view the comments powered by Disqus.blog comments powered by

Viewing all articles
Browse latest Browse all 9433

Trending Articles