320 views
2 2 votes

Which of the following statement(s) is/are TRUE regarding Lexical Analysis and Regular Expressions?

  1. The number of states in a minimal Deterministic Finite Automaton (DFA) for the language $L=\left\{w \in\{a, b\}^* \mid\right.~w \text{contains 'aba' as a substring\}}$ is $4$.
     
  2. If a lexical analyzer is implemented using a Non-deterministic Finite Automaton (NFA), it will always be more space-efficient than a DFA implementation, but might be slower in terms of time complexity. 
     
  3. The language $L=\left\{a^n b^n \mid n \geq 0\right\}$ cannot be recognized by a lexical analyzer.
 
 
  1. I, II, AND III
     
  2. I AND III ONLY
     
  3. II AND III ONLY
     
  4. I AND II ONLY

2 Answers

2 2 votes

Statement I (TRUE): To recognize a substring of length $n$ (like "aba", where $n=3$ ), a minimal DFA generally requires $n+1$ states. For "$aba$", the states represent$: (1)$ Initial/nothing, $(2)$ '$a$' seen, $(3) $'$ab$' seen, and $(4)$ '$aba$' seen (final state).

Statement II (FALSE): While an NFA can be more space-efficient (fewer states) than a DFA, it is not "always" the case for every implementation. Furthermore, lexical analyzers in practice (like Flex) almost always convert the NFA to a DFA to ensure $O(1)$ time complexity per character, prioritizing speed over theoretical space savings.

Statement III (TRUE): The language $L=\left\{a^n b^n \mid n \geq 0\right\}$ is a Context-Free Language that is not regular. Since lexical analyzers are based on Finite Automata (which have no memory/count mechanism), they cannot recognize languages that require matching or counting, such as $a^n b^n$.

Answer:
Position:
Show:

Related questions

2 2 votes
3 3 answers
575
575 views
GO Classes asked Feb 4
575 views
A lexical analyzer is designed for a new language with the following rules for token generation:$\mathrm{KEYWORD1}: \verb|if|$ $\mathrm{KEYWORD2}: \verb|iff|$ $\mathrm{ID...
2 2 votes
5 5 answers
579
579 views
GO Classes asked Feb 4
579 views
Consider the following arammar $G$ :$$\begin{aligned}& S \rightarrow(L) \mid a \\& L \rightarrow L, S \mid S\end{aligned}$$Which of the following statement(s) is/are TRUE...
5 5 votes
2 2 answers
312
312 views
GO Classes asked Feb 4
312 views
Consider a Bottom-Up parser for a grammar $G$. During the parsing of an input string $w$, the parser reaches a configuration where the stack contains the prefix $\alpha$ ...
1 1 vote
2 2 answers
315
315 views
GO Classes asked Feb 4
315 views
Consider the following Syntax Directed Translation (SDT) scheme where $S$ is the start symbol and $id.\mathrm{val}$ represents the numerical value of an identifier:$$\beg...