Complexity class P ~ set of all decision problems that can be solved by a deterministic Turing machine in polynomial time. A decision problem is a problem which can be stated as a yes/no question.
So how would you formally classify problems such as:
- find the maximum number in an unsorted list of length n?
- what is the shortest path in a weighted, undirected graph?
Clearly these problems can be solved in polynomial time, but they are not decision problems.
This however is different for NP-complete versus NP-hard problems. Example (TSP):
- TSP (decision version): does there exist a tour that visits all cities, and costs less than L? (NP-complete)
- TSP (optimization version): what is the shortest tour that visits all cities? (NP-hard).
In other words, the class of NP-hard problems is not restricted to decision problems; it can also contain search or optimization problems. So why do most (all?) definitions of complexity class P limit the definition to decision problems?