- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
如果您已经拥有该算法的伪代码,它们是否有任何有用的指南来描述图灵机的功能?
我正在修一门关于复杂性理论的类(class),我需要花一些时间来描述决定或接受某种语言(状态、转换等)的图灵机,尽管我知道如何用 C 甚至汇编之类的语言对其进行编码.我想我只是没有足够的图灵机练习(正在研究它),但我感谢任何建议。
编辑
我不想制作图灵机模拟器,我想在纸上描述图灵机(字母、状态、转换)来决定某种语言。
这是我的意思的一个简单示例,假设我需要编写一个图灵机,它遍历一串 0 和 1,并将其中的所有 0 更改为 1。例如,如果您从磁带(输入)上的 11010 开始,它会在磁带(输出)上以 11111 停止。现在在高级语言中你知道它是这样的:
Go over every character on tape
If character is 0 change it to 1
You have two states, q and halt. When you are on state q and you see a 1, go to the right without changing it. If you see a 0, change it to 1 and go to the right. If you see the blank symbol (end of tape) then go to the halt state.
最佳答案
免责声明:你的问题很笼统,因此这个答案也是如此。请注意,我绝不是 TM 专家,而且
这种方法通常不是很有效(我什至不能保证它总是有效)。
我只是在这里记下一些想法。
我建议尝试这样的方法:使用你的伪代码并减少它,以便
它只包含 a) bool 变量和 b) if
- 声明。
例如:
if THIS_LETTER_IS("A"):
found_an_even_number_of_A = not found_an_even_number_of_A
if THIS_LETTER_IS("Q") and previous_letter_was_X and found_an_even_number_of_A
and not checking_for_alternative_2:
# can't be a word of alternative 1, so check for alternative 2
going_back_to_start_to_check_for_alternative_2 = True
if going_back_to_start_to_check_for_alternative_2:
MOVE_TO_PREVIOUS
else:
MOVE_TO_NEXT
if going_back_to_start_to_check_for_alternative_2 and THIS_LETTER_IS(EMPTY):
# reached the beginning, so let's check for alternative 2
going_back_to_start_to_check_for_alternative_2 = False
checking_for_alternative_2 = True
if
s,将它们替换为
and
s;删除
else
使用
not
阻止:
if something:
if something_else:
do_a
else:
do_b
if something and something_else:
do_a
if something and not something_else:
do_b
if
块应该只包含一个
MOVE_TO_PREVIOUS
或
MOVE_TO_NEXT
,可能是
WRITE
命令和任何数字
if
子句,这样你的每一个 bool 值和当前字母总是被检查,重复
if something and something_else:
do_a
if THIS_LETTER_IS("A") and something and something_else and something_i_dont_care_about_here:
do_a
if THIS_LETTER_IS("A") and something and something_else and not something_i_dont_care_about_here:
do_a
if THIS_LETTER_IS("Q") and something and something_else and something_i_dont_care_about_here:
do_a
if THIS_LETTER_IS("Q") and something and something_else and not something_i_dont_care_about_here:
do_a
if
s。
if THIS_LETTER_IS("A") and bitfield[0] and bitfield[1] and bitfield[2]:
do_a
if THIS_LETTER_IS("A") and bitfield[0] and bitfield[1] and not bitfield[2]:
do_a
# ...
if THIS_LETTER_IS("A") and bitfield == 7:
do_a
if THIS_LETTER_IS("A") and bitfield == 3:
do_a
# ...
do_a
部分只是对 bool 值的赋值(即位域,所以它是你的新状态),一个写命令(如果没有,只需写下已经存在的字母
关于automata - 设计图灵机的状态表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2099650/
我花了整整一个月才解决这个问题,因为我是从练习一本书中得到的,我很想知道如何在图灵机中编写它;我真的很想学习这个。请问有人可以提供帮助吗? Consider the last two letters
已锁定。这个问题及其答案是locked因为这个问题是题外话,但却具有历史意义。目前不接受新的答案或互动。 好了大家,今天的目标是构建一个图灵机模拟器。对于那些不知道它是什么的人,请参阅 the Wik
我是最后一年的工程专业学生。我和我的 friend 们决定我们的最后一年项目是“使用模板元编程模拟图灵机”。 我明白什么是“图灵机”和“模板元编程”,但我的问题是如果我们设计没有 TMP 的图灵机,为
我需要为语言 L = {w| 构建一个只有 1 个磁带的 TM w 是一个单词中 a 和 b 的个数相同,例如:abba, aababb} TM 必须只有 1 个磁带并且必须在 O(nlog(n))
我是一名优秀的程序员,十分优秀!