COMP 455: Models and languages of Computation Homework 3Matlab

Java Python Homework Assignment 3:

COMP 455: Models and languages of Computation

DEADLINE: 11:59 P.M., Wednesday, Oct 16, 2024

Problem 1: (16 points; 4 parts) Design CFGs for the following languages. Follow the format presented in the class for specifying CFGs.

1.1 (4 points) L consists of all the strings over the alphabet {0, 1} which contain at least three 0’s or at least two 1’s.

1.2 (4 points) L = {w010w ′ | w, w′ ∈ {0, 1}*and |w| = |w ′ |}

1.3 (4 points) L is the language over the alphabet {a, b, c} given by L = {a i b j c k | i = j ri = k, and i, j, k ≥ 1}.

1.4 (4 points) The alphabet is {a, b, c, d} and L = {a nb mc md n | n, m ≥ 0}

Problem 2: (10 points; 4 parts) Let w = (())()(). Consider the grammar:

S → SS | (S) | ()

2.1 (4 points) Construct a parse tree whose yield is w.

2.2 (2 points) Give the leftmost derivation of w using your parse tree.

2.3 (2 points) Give the rightmost derivation of w using your parse tree.

2.4 (2 points) Give a derivation of w that is neither the leftmost nor the rightmost derivation.

Problem 3: (4 points; 1 part) Consider the CFG G = ({S, A}, {0, 1}, P, S) with P being:

S → AS | ϵ

            A → A0 | 1A0 | 10

This grammar is known to be ambiguous. COMP 455: Models and languages of Computation Homework Assignment 3Matlab Exhibit a string and two different parse trees for the string.

Problem 4: (10 points; 4 parts)

Consider the PDA in the above figure. It accepts using final states.

4.1 (4 points) Using IDs (instantaneous descriptions) derive a successful execution sequence using which the PDA accepts the string 1011000.

Diagram repeated for convenience

4.2 (2 points) Is the string 110 accepted by this PDA? if your answer is yes, show a successful execution sequence using IDs. If your answer is no then show that all executions sequences get stuck before finishing to read the string or end in a non-accepting state after processing string.

4.3 (2 points) Describe in informal terms the language recognized by this PDA.

4.4 (2 points) Convert this PDA into an equivalent PDA that accepts using the empty stack criterion. Show the transition diagram of this PDA.

Problem 5: (8 points; 2 parts) Consider the CFG (V, T, P, S) where V = {S, A, B}, T = {0, 1}, and P is as follows:

S → AS | A

       A → 0A | 1B | 1

B → 0B | 0

5.1 (4 points) Construct a PDA that accepts—via empty stack—the language generated by the above CFG. You must use the procedure shown in the class. Show the transition diagram of this PDA.

5.2 (4 points) Show also your PDA in the 7-tuple form. Clearly list each component of your 7-tuple         

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值