A way of grouping algorithms, computable functions, or specifications according to their computational complexity. Computable functions that have the same complexity according to some measure are placed in the same complexity class; functions in the same class are equally difficult to compute with respect to the measure.
The classification is most thoroughly done for formal languages that can be recognized by Turing machines. If L is a formal language that can be recognized by a deterministic Turing machine program M, and the time complexity (see complexity measure) for M is a function TM(n) of the length n of the input string, then L is classified according to the nature of TM(n). If TM(n) is bounded (e.g. by a polynomial or exponential function) then there exists a bounding function S(n) such that for all n, TM(n) ≤ S(n) For a particular function S(n) there is consequently a class of languages for which the above bound on time holds. This class is denoted by DTIME(S(n) Thus DTIME(S(n) is the class of languages recognizable within time S(n).
TM(n) ≤ S(n)
There is a similar definition of a class of languages DSPACE(S(n) in terms of the space complexity (see complexity measure).
There are various known relations between complexity classes. For example, if for two bounding functions S1 and S2 then there is a language in DSPACE(S2(n) that is not in DSPACE(S1(n). Note that this applies if S1 is polynomial and S2 is exponential. There are similar results for time complexity classes.
Complexity classes can also be defined for nondeterministic Turing machine programs. Thus a language L is in NSPACE(S(n) if there is some nondeterministic Turing machine program that recognizes L and such that on an input string of length n none of the possible computations uses more than S(n) tape squares. Time complexity classes, NTIME, can be similarly defined. It is known for example that NSPACE(S(n) ⊆ DSPACE(S(n)2)
NSPACE(S(n) ⊆ DSPACE(S(n)2)