# GATE | GATE-CS-2007 | Question 30

The language L= {0i21i | iâ‰¥0 } over the alphabet {0,1, 2} is: (A) not recursive (B) is recursive and is a deterministic CFL. (C) is a regular language. (D) is not a deterministic CFL but a CFL.

Explanation: Let us firstÂ design a deterministic pushdown automata for the given language.
• For each occurrence of â€˜0â€™ , we PUSH X in the stack.
• When â€˜2â€™ appears, no stack operation is performed. But, state of the automata is changed.
• For each occurrence of â€˜1â€™ , we POP X from the stack.
• If at the end Z0 is on the stack top then input string is accepted
We also design a Turing machine for the given language.
• When â€˜0â€™ appears in the input string , we replace it with X .Then, traverse to the rightmost corner and replace â€˜1â€™ with Y.
• We go back to the leftmost â€˜0â€™ and repeat the above process.
• While traversing rightwards from the beginning of the input string, if after X, â€˜2â€™ appears and after â€˜2â€™, Y appears then we reach the HALT state. Thus, the given language is recursive. Every recursive language is a CFL. Thus, option (B) is the answer. Please comment below if you find anything wrong in the above post.

Quiz of this Question

Previous
Next