a = fromSomeAlgo();
if(a > foo)
stateA();
else
stateB();
But for 非确定性图灵机 I read https://stackoverflow.com/questions/3671429/why-are-np-problems-called-that-way-and-np-hard-and-np-complete,在给定时间它可以处于多种状态。也维基百科文章 http://en.wikipedia.org/wiki/Non-deterministic_Turing_machine建议“非确定性图灵机(NTM)可能有一组规则,规定了更多
而不是针对特定情况的一项行动”.
例如,让我们看看子集和问题 http://en.wikipedia.org/wiki/Subset_sum_problem, with S = {a,b,c... }。非确定性图灵机有一个线性解:
for each element:
"guess" if it is in the subset
check if the subset has the specified sum
生成的树将是这样的:
start
with a without a
/ \ / \
/ \ / \
/ \ / \
with b without b with b without b
/ \ / \ / \ / \
with c without c with c without c with c without c with c without c