1. In Example 14.6, show how a trial solution can be generated in O(n) time.
This means that all 2n possibilities must be generated in a decision tree with
height O(n).
EXAMPLE 14.6
Reconsider the SAT problem. We made some rudimentary argument
to claim that this problem can be solved efficiently by a nondeterministic
Turing machine and, rather inefficiently, by a brute-force
exponential search. A number of minor points were ignored in that
argument.
Suppose that a CNF expression has length n, with m different
literals. Since clearly m < n, we can take n as the problem size. Next,
we must encode the CNF expression as a string for a Turing machine.
We can do this, for example, by taking Σ = {x,∨,∧, (, ),−, 0, 1} and
encoding the subscript of x as a binary number. In this system, the
CNF expression (x1 ∨ x2) ∧ (x3 ∨ x4) is encoded as
(x1 ∨ x − 10) ∧ (x11 ∨ x100).
Since the subscript cannot be larger than m, the maximum length of
any subscript is log2m. As a consequence the maximum encoded length
of an n-symbol CNF is O(nlogn). The next step is to generate a trial solution for the variables. Nondeterministically,
this can be done in O(n) time. (See Exercise 1 at
the end of this section.) This trial solution is then substituted into the
input string. This can be done in O(n2logn) time∗. The entire process
therefore can be done in O(n2logn) or O(n3) time, and SAT ∈ NP.