这是一个执行 http://readingtaocp.wordpress.com/2008/09/13/markov-algorithms-in-scala/该练习的答案。也许有帮助。
顺便说一句,该表似乎描述了一个马尔可夫算法 http://en.wikipedia.org/wiki/Markov_algorithm.
As far as I understand so far, you start with the first command set, j = 0. Replace any occurencies of Tj with sj and jump to the next command line depending on if you replaced anything (in that case jump to bj, if nothing has been replaced, jump to aj).
编辑:新答案:
A = {a,b,c} 似乎是您可以操作的字符集。 c 在算法过程中出现(添加到左侧,后来再次被 a 替换)。
Theta 和 phi 可能是您通常用于“原始”和“替换”之类的希腊字符,尽管我不知道它们是什么。
bj and aj are the table lines to be next executed. This matches with the human-readable descriptions in the last column.
我唯一无法回答的是为什么 Knuth 在没有任何解释的情况下使用这个符号。我又浏览了一遍书中的前几章和解决方案,他没有在任何地方提到这一点。
EDIT2:gdc(2,2) = 2 的示例
Input string: aabb
Line 0: Remove one a and one b, or go to 2.
=> ab => go to 1
Line 1: Add c at extreme left, go back to 0.
=> cab => go to 0
Line 0: Remove one a and one b, or go to 2.
=> c => go to 1
Line 1: Add c at extreme left, go back to 0.
=> cc => go to 0
Line 0: Remove one a and one b, or go to 2.
No ab found, so go to 2
Line 2: Change all a's to b's
No a's found, so go to 3
Line 3: Change all c's to a's
=> aa
Line 4: if b's remain, repeat
No b's found, so go to 5 (end).
=> Answer is "aa" => gdc(2,2) = 2
顺便说一句,我认为第 1 行的描述应该是“删除一个“ab”,或转到第 2 行”。这让事情变得更清楚了一些。