Question 4Medium
Regular languages are closed under
- Union only
- Complement only
- Union, intersection and complement
- None of these
Answer: C. Union, intersection and complement
Explanation
Regular languages are closed under union, intersection, complement, concatenation, star and reversal.
Step-by-step solution
- Regular languages are closed under union, intersection, complement, concatenation, star and reversal.
- So the answer is: Union, intersection and complement.
Why the other options are wrong
- A. They are also closed under intersection and complement.
- B. They are also closed under union.
- D. They are closed under union, intersection and complement, so 'none' is wrong.
Question 5Medium
Which language is context-free but not regular?
- a*b*
- { a^n b^n c^n | n >= 0 }
- { a^n b^n | n >= 0 }
- (ab)*
Answer: C. { a^n b^n | n >= 0 }
Explanation
A PDA pushes a for each a and pops for each b, so a^n b^n is context-free.
Step-by-step solution
- A PDA pushes a for each a and pops for each b, so a^n b^n is context-free.
- So the answer is: { a^n b^n | n >= 0 }.
Why the other options are wrong
- A. a*b* is regular.
- B. a^n b^n c^n is not context-free.
- D. (ab)* is regular.
Question 9Hard
How many strings of length 4 over {a,b} do NOT contain "aa" as a substring?
- 6
- 10
- 12
- 8
Answer: D. 8
Explanation
The count follows the Fibonacci pattern: lengths 1,2,3,4 give 2,3,5,8 strings.
Step-by-step solution
- The count follows the Fibonacci pattern: lengths 1,2,3,4 give 2,3,5,8 strings.
- So the answer is: 8.
Why the other options are wrong
- A. 6 undercounts.
- B. 10 overcounts.
- C. 12 overcounts.
Tip: To count strings with no 'aa', add the two previous totals: 2, 3, 5, 8 for lengths 1 to 4.
Question 10Hard
Context-sensitive languages are recognised by
- Finite automata
- Pushdown automata
- Mealy machines
- Linear bounded automata
Answer: D. Linear bounded automata
Explanation
An LBA is a Turing machine whose tape is limited to the input length.
Step-by-step solution
- An LBA is a Turing machine whose tape is limited to the input length.
- So the answer is: Linear bounded automata.
Why the other options are wrong
- A. Finite automata recognise regular languages.
- B. PDAs recognise CFLs.
- C. Mealy machines transduce.
Tip: Context-sensitive languages go with a linear bounded automaton, a machine whose tape is limited to the input length.