Let Σ = {0, 1} and let B be the collection of strings that contain at least one 1 in their second half. In other words,B = {uv|u ∈ Σ∗, v ∈ Σ∗1Σ∗ and |u| ≥ |v|}(a) Give a Push-Down Automata (PDA) that recognises B.(b) Give a Context-Free Grammar (CFG) that recognises B.
Question
Let Σ = {0, 1} and let B be the collection of strings that contain at least one 1 in their second half. In other words,B = {uv|u ∈ Σ∗, v ∈ Σ∗1Σ∗ and |u| ≥ |v|}(a) Give a Push-Down Automata (PDA) that recognises B.(b) Give a Context-Free Grammar (CFG) that recognises B.
Solution
(a) A Push-Down Automata (PDA) that recognises B can be constructed as follows:
States: {q0, q1, q2, q3} Input alphabet: Σ = {0, 1} Stack alphabet: Γ = {0, 1, $} Start state: q0 Accept states: {q3} Transition function: δ
The transition function δ is defined as follows:
- δ(q0, ε, ε) = {(q1, )}: On empty input, push onto the stack and move to state q1.
- δ(q1, 0, ε) = {(q1, 0)}: On input 0, push 0 onto the stack and stay in state q1.
- δ(q1, 1, ε) = {(q1, 1)}: On input 1, push 1 onto the stack and stay in state q1.
- δ(q1, ε, 0) = {(q2, ε)}: On empty input, pop 0 from the stack and move to state q2.
- δ(q1, ε, 1) = {(q2, ε)}: On empty input, pop 1 from the stack and move to state q2.
- δ(q2, 0, 0) = {(q2, ε)}: On input 0, pop 0 from the stack and stay in state q2.
- δ(q2, 0, 1) = {(q2, ε)}: On input 0, pop 1 from the stack and stay in state q2.
- δ(q2, 1, 0) = {(q2, ε)}: On input 1, pop 0 from the stack and stay in state q2.
- δ(q2, 1, 1) = {(q2, ε)}: On input 1, pop 1 from the stack and stay in state q2.
- δ(q2, ε, from the stack and move to state q3.
(b) A Context-Free Grammar (CFG) that recognises B can be constructed as follows:
Variables: S, A, B Terminals: 0, 1 Start symbol: S Production rules:
- S → 0S | 1S | A
- A → 0A | 1A | B
- B → 1 | 01 | 11
This CFG generates all strings that contain at least one 1 in their second half.
Similar Questions
Design a PDA for the language consisting of strings with more 0's than 1's.
Which regular grammar generates the language consisting of strings with zero or more occurrences of "a" followed by "b"? Options : S -> ab | aS | ε S -> a | b | aS S -> ab | aS none
Which of the following is the corresponding Language to the given DFA? L= {x ϵ {0,1} |x ends in 1 and does not contain substring 10}L= {x ϵ {0, 1} * | x ends in 1 and does not contain substring 01}L= {x ϵ {0,1} * |x ends in 1 and does not contain substring 00}L= {x ϵ {0,1} * |x ends in 1 and does not contain substring 11}
For the following language over Σ = {a, b}, provide a regular expression and a DFA for the language. Your automata should have at most 10 states.The set of strings that contain exactly three as and an even number of bs. For example, abababb is in the language, while ababab is not.
Which of the following can accept even palindrome over {a,b}ans.Push down AutomataAll of the mentionedTuring machineNDFA
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.