NTU-Exam 板


LINE

课程名称︰自动机与形式语言 课程性质︰必修 课程教师︰林智仁 开课学院:电机资讯学院 开课系所︰资讯工程学系 考试日期(年月日)︰107.12.3 考试时限(分钟):160 试题 : Introduction to the Theory of Computation Midterm 2 December 3, 2018 10:20-13:00 ● Please write your answers in English. ● Please give details of your answers. A direct answer without explanation is not ciunted. ● Read the problem statements carefully. ● During the exam, you are not allowed to borrow others' notes. ● The problems may not be ordered according to difficulty. Try to work on easier problems first. Problem 1 (10 pts). Transform the following CFG to Chomsky Normal Form(CNF). S→00S|0A|1A A→11A|ε Problem 2 (35 pts). Consider the language L = {ww^R|w∈{0, 1}*}, where w^R denotes the reverse of w. (a) (5 pts) In th lecture/textbook we showed a 4-state PDA for L as follows. ε, ε→$ ─┐ 0, ε→0 →q1─────→q2←┘ 1, ε→0 │ │ε, ε→$ │ ↓ (q4)←─────q3─┐ 0, 0→ε ε,$ → ε ←┘ 1, 1→ε Draw the trees of running ● 0110 ● 1010 You need to show all nodes that can be reached by ε links. (b) (10 pts) For the language L, give a CFG with one variable and 3 rules. Explain in detail why it has the smallest number of rules. (c) (10 pts) For the CFG obtained in (b), generate a corresponding PDA with the procedure in Lemma 2.21 of the textbook. Draw the tree of running 0110. You need to show all nodes that can be reached by ε links. Hint: There must be at least 25 nodes; otherwise it is wrong. (d) (10 pts) Now we would like to generate a corresponding CFG with the procedure in Lemma 2.27 of the textbook. There are three required feature for the PDA: (i) It has a single accept state. (ii) It empties its stack before accepting. (iii) Each transition either pushes one symbol onto the stack or pops one off the stack, but not both at the same time. Dose the PDA in (a) satisfy all of them? If so, briefly show why each requirement is satisfied. If not, give a PDA with no more than 5 states satisfying the requirements. You are NOT allowed to change Σ or Γ. Than generate the corresponding CFG and give its formal definition. Problem 3 (30 pts). Consider the following NFA for the language M described by the regular expression (01)* 0 ─────→ →(q1) q2 ←───── 1 (a) (10 pts) Give a CFG with one variable and the smallest number of rules for M. We further require that the total lengths if the rules is minimized. Explain why yours satisfies this requirement. (b) (10 pts) Now we modify the edges of the NFA to make it become the following PDA. 0, ε→ε ─────→ →(q1) q2 ←───── 1, ε→ε Does the PDA satisfy all the requirements in Lemma 2.27? If not, give a modified PDA with Γ = {0} to meet the requirements. Then apply the procedure in Lemma 2.27 to generate a CFG for M. You may use A_ij to represent A_qi,qj for simplicity. (c) (10 pts) From the CFG obtained in (b), extract a small subset of no more than 7 rules, then further simplify these rules to your solution in (a). Hence this procedure shows that the subset of rules you choose can generate M. Hints: ● You may need to apply similar techniques for transforming a CFG to CNF. ● At some point you may need to extract several rules again in order to generate your solution in (a). ● You may need to use the fact that the sets of rules in (a) and (b) both generate M. Problem 4 (25 pts). Consider the language {w$|w∈{0, 1}*, #0(w) = #1(w)}, where #i(w) is the number of occurences of i in w. (a) (10 pts) Design a PDA with no more than 3 states for this language. We further require that Γ={0, 1, $}. Explain why it is not a deterministic PDA (DPDA). (b) (15 pts) Design a DPDA with at most 8 states for this language. We still require that Γ = {0, 1, $}. Hint: To avoid non-determinism, you may transform a transition ε to two. Simulate and draw the trees of running ● 0011$ ● 1$ -- 在很久的以後 你是否记得我 --



※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 140.112.150.17
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/NTU-Exam/M.1543942427.A.C08.html
1F:推 rod24574575 : 已收资讯系! 12/05 08:44







like.gif 您可能会有兴趣的文章
icon.png[问题/行为] 猫晚上进房间会不会有憋尿问题
icon.pngRe: [闲聊] 选了错误的女孩成为魔法少女 XDDDDDDDDDD
icon.png[正妹] 瑞典 一张
icon.png[心得] EMS高领长版毛衣.墨小楼MC1002
icon.png[分享] 丹龙隔热纸GE55+33+22
icon.png[问题] 清洗洗衣机
icon.png[寻物] 窗台下的空间
icon.png[闲聊] 双极の女神1 木魔爵
icon.png[售车] 新竹 1997 march 1297cc 白色 四门
icon.png[讨论] 能从照片感受到摄影者心情吗
icon.png[狂贺] 贺贺贺贺 贺!岛村卯月!总选举NO.1
icon.png[难过] 羡慕白皮肤的女生
icon.png阅读文章
icon.png[黑特]
icon.png[问题] SBK S1安装於安全帽位置
icon.png[分享] 旧woo100绝版开箱!!
icon.pngRe: [无言] 关於小包卫生纸
icon.png[开箱] E5-2683V3 RX480Strix 快睿C1 简单测试
icon.png[心得] 苍の海贼龙 地狱 执行者16PT
icon.png[售车] 1999年Virage iO 1.8EXi
icon.png[心得] 挑战33 LV10 狮子座pt solo
icon.png[闲聊] 手把手教你不被桶之新手主购教学
icon.png[分享] Civic Type R 量产版官方照无预警流出
icon.png[售车] Golf 4 2.0 银色 自排
icon.png[出售] Graco提篮汽座(有底座)2000元诚可议
icon.png[问题] 请问补牙材质掉了还能再补吗?(台中半年内
icon.png[问题] 44th 单曲 生写竟然都给重复的啊啊!
icon.png[心得] 华南红卡/icash 核卡
icon.png[问题] 拔牙矫正这样正常吗
icon.png[赠送] 老莫高业 初业 102年版
icon.png[情报] 三大行动支付 本季掀战火
icon.png[宝宝] 博客来Amos水蜡笔5/1特价五折
icon.pngRe: [心得] 新鲜人一些面试分享
icon.png[心得] 苍の海贼龙 地狱 麒麟25PT
icon.pngRe: [闲聊] (君の名は。雷慎入) 君名二创漫画翻译
icon.pngRe: [闲聊] OGN中场影片:失踪人口局 (英文字幕)
icon.png[问题] 台湾大哥大4G讯号差
icon.png[出售] [全国]全新千寻侘草LED灯, 水草

请输入看板名称,例如:WOW站内搜寻

TOP