Problems, Algorithms and Time Complexity
We introduce here the elementary concepts of computer science and complexity theory which will be useful in understanding the material of the other appendices. This appendix is primarily intended for those readers who do not have a background in computer science. Its main aim is that of presenting basic notions about computational problems, the axiomatic definition of algorithms, the standard methods to represent algorithms, the concept of time complexity and a few useful tools to estimate the time complexity of simple algorithms. Whenever possible, the discussion has been intentionally left informal and all the unnecessary technicalities have been discarded, in order to allow the reader to focus on the essential concepts without being distracted by definitions and theorems. For a more formal treatment of the material presented in this appendix we encourage the interested reader to refer to any classical book on algorithms, such as the trilogy by Donald Ervin Knuth [181, 182, 183] or in Complexity Theory [250].
What Is a “Problem”?
Formally, a problem P is a pair (D,Q) of an abstract description D and a question Q requiring an answer. A simple example of a problem in graph theory is the Graph Connectivity Problem: “Given a graph G(N,L) where N denotes a set of vertices and L is the set of edges among vertices in N, is the graph G connected?” In this example, the description provides the context of the problem, which is usually represented as a class of objects (a generic graph G(N,L)), while the question to be answered (“is G connected?”) is a precise enquiry about a specific property of the class of objects under consideration.
The definition above is quite general and is given for an entire class of objects, without any specific connection to a particular object of that class. Conversely, an instance of a problem includes a full specification of one particular object of a class, which we indicate as x, and the solution P(x) is the answer to the question Q for the specific object x under consideration.