Question
Consider the following languages:
Which one of the following is TRUE?
Official answer and solution
- Official answer
- B
- From
- Official GATE 2016 answer key
Solution
Determine whether each language can be recognized by a single-stack pushdown automaton.
Analyze :
Notice that contains copies of . We can recognize with a deterministic pushdown automaton (DPDA):
- Push each incoming onto the stack (recording ).
- Push each incoming onto the stack (recording ).
- For each incoming , pop a from the stack until all 's are matched, then continue popping an for each subsequent until all 's are matched.
- If the stack is empty exactly when the input ends, accept.
Because a PDA with a single stack accepts , is context-free (in fact, a deterministic CFL). A CFG for is:
Analyze :
Here, the number of 's, 's, and 's are all tied to the same count . A pushdown automaton cannot simultaneously verify that the number of 's equals the number of 's and that the number of 's equals twice that number using a single stack.
Applying the Pumping Lemma for CFLs to : Let be the pumping length and choose . Any decomposition with and can contain at most two distinct symbols among . Pumping and alters the counts of at most two symbol types while leaving the third unchanged, producing strings not in . Hence, is not context-free.
Therefore, is context-free while is not context-free.
B
Thinking that three variables in require two stacks, missing that the reverse order of popping allows matching both and against .
The answer is the one in the official GATE answer key. The solution is this site's own explanation.
Source
- Paper
- GATE 2016 Computer Science and Information Technology (CS) Session 2
- Question
- 53 of 65, printed as CS Q.43
- Section
- Computer Science and Information Technology
Report an error in this question
GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.