automation - 如何解决这个上下文无关语法

标签 automation context-free-grammar pushdown-automaton

给出上下文无关语法

{w | w is an element of {a, b, c, d}* such that # of a+ # of b = # of c + # of D}

how do i approach this question...?

最佳答案

这个怎么样:

S -> A C S     
S -> A S C                   
S -> S A C                 

S -> C A S     
S -> C S A                   
S -> S C A

S -> 
A -> a|b
C -> c|d

(可能有更优雅的解决方案...)

至于如何处理这些问题,我认为关键的见解通常在于分组(此处为 A 和 C),但我认为最好的学习方法是了解很多例子并尝试很多问题 - 例如this one .

关于automation - 如何解决这个上下文无关语法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13151232/

相关文章:

android - 在 Recycler View 内单击 : Espresso

angularjs - 当我在 Protractor cucumber 步骤定义的when部分定义{string}参数时,未定义

python - 我可以在机器人框架中编写独立的测试用例吗?

java - 如何获取cucumber中自动生成的Glue代码/步骤定义文件?

python - 如何解析上下文无关语法中的特殊字符?

stack - 是否有一种编程语言仅具有确定性下推自动机的功能,而仅此而已?

automata - 在下推自动机中以相反的顺序压入/弹出堆栈

context-free-grammar - 回文下推自动机

context-free-grammar - 是 { w | w <> w^R } 在字母表 {0,1} 上是一种上下文无关的语言?

finite-automata - 有限自动机、下推自动机和图灵机示例