Asked By : jmite
Answered By : jmite
$L = {w mid w$ is the encoding of an input $y$ to problem $X$, and the answer to input $y$ for problem $X$ is “Yes” $ }$
Determining if the answer for an input to a decision problem is “yes” is equivalent to determining whether an encoding of that input over an alphabet is in the corresponding language. Algorithm: An algorithm is a step-by-step way to solve a problem. Note that there an algorithm can be expressed in many ways and many languages, and that there are many different algorithms solving any given problem. Turing Machine: A Turing Machine is the formal analogue of an algorithm. A Turing Machine over a given alphabet, for each word, either will or won’t halt in an accepting state. Thus for each Turing Machine $M$, there is a corresponding language:
$L(M) = {w mid M$ halts in an accepting state on input $w}$.
(There’s a subtle difference between Turing Machines that halt on all inputs and halt on yes inputs, which defines the difference between complexity classes $mathsf{R}$ and $mathsf{RE}$.) The relationship between languages and Turing Machines is as follows
- Every Turing Machine accepts exactly one language
- There may be more than one Turing Machine that accept a given language
- There may be no Turing Machine that accepts a given language.
We can say roughly the same thing about algorithms and problems: every algorithm solves a single problem, but there may be 0, or many, algorithms solving a given problem. Time Complexity: One of the most common sources of confusion between algorithms and problems is in regards to complexity classes. The correct allocation can be summarized as follows:
- An algorithm has a time complexity
- A problem belongs to a complexity class
An algorithm can have a certain time complexity. We say an algorithm has a worst-case upper-bounded complexity $f(n)$ if the algorithm halts in at most $f(n)$ steps for any input of size $n$. Problems don’t have run-times, since a problem isn’t tied to a specific algorithm which actually runs. Instead, we say that a problem belongs to a complexity class, if there exists some algorithm solving that problem with a given time complexity. $mathsf{P}, mathsf{NP}, mathsf{PSPACE}, mathsf{EXPTIME}$ etc. are all complexity classes. This means they contain problems, not algorithms. An algorithm can never be in $mathsf{P}$, but if there’s a polynomial-time algorithm solving a given problem $X$, then $X$ is in $mathsf{P}$. There could also be a bunch of exponential-time algorithms accepting $X$, but since there exists a single polynomial-time algorithm accepting $X$, it is in $mathsf{P}$.
Best Answer from StackOverflow
Question Source : http://cs.stackexchange.com/questions/13669