产生字符串翻转和反转的下推自动机

发布于 2024-10-02 11:07:33 字数 509 浏览 0 评论 0原文

字母表:0, 1

考虑翻转,翻转每个字符:0 -> 1; 1-> 0 因此,如果 w = 0011 则 w-flip = 1100

将反转视为反转顺序的字符 因此,如果 w = 01101 那么 w-reverse = 10110

现在我正在尝试生成一个 PDA,它接受字符串 w,然后打印 w,打印 (w-flip-reversed)

w = 011
w-flip = 100
w-flip-reverse = 001

所以这将打印:“011001”

考虑 # 为一个空白字符。所以一个字符串会开始 #011#

转换表看起来像这样:

State:    Symbol Read:    Next State:    Head Instruction:
start     #               r1             L

等等

有什么想法吗?

The alphabet: 0, 1

Consider a flip, to flip each character: 0 -> 1; 1 -> 0
So if w = 0011 then w-flip = 1100

Consider a reverse to be the characters in reversed order
So if w = 01101 then w-reverse = 10110

Now I am trying to produce a PDA which takes the string w, and then prints w, prints (w-flip-reversed)

w = 011
w-flip = 100
w-flip-reverse = 001

So this would print: "011001"

Consider # to be a blank character. So a string would start #011#

Transition table looks something like this:

State:    Symbol Read:    Next State:    Head Instruction:
start     #               r1             L

And so on

Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

傲性难收 2024-10-09 11:07:33

打印出字符串很简单(我希望)。打印翻转就像在读取 1 时打印 0 一样简单,反之亦然。

一个让您继续反转的粗略草图:

  • 您需要一个地方来将字符串一块一块地放置,以便于反转,因此先进后出存储是理想的(这在 PDA 中可能是什么?)。
  • 然后,您需要观察字符串的末尾,以便知道何时从存储字符串(以便轻松反转)切换到输出。
  • 那么你需要以正确的相反顺序检索字符串的每个部分(如果存储的 FILO 是微不足道的)并输出它,当到达字符串末尾时停止。

在您的情况下,您需要将翻转的字符串放入存储中以进行反转。

Printing out the string is simple (I hope). Printing out the flip is as easy as printing out 0 when you read a 1 and vice-versa.

A rough sketch to get you going on the reversal:

  • You need a place to put the string piece by piece that lends itself to reversal, so first-in-last-out storage is ideal (What might this be in a PDA?).
  • Then you need to watch for the end of the string so you know when to switch from storing the string for easy reversal to output.
  • then you need to retrieve each piece of the string in the correct reverse order (which if stored FILO is trivial) and output it, stopping when you reach the end of the string.

In your case, you'll need to put the flipped string in storage for reversal.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文