All Exams  >   Computer Science Engineering (CSE)  >   Compiler Design  >   All Questions

All questions of Lexical Analysis for Computer Science Engineering (CSE) Exam

Given a NFA with N states, the maximum number of states in an equivalent minimized DFA is at least.
a) 2N
b) 2^N
c) N!
d) none of these
Correct answer is option 'B'. Can you explain this answer?

Arindam Goyal answered
Solution:

The given question is related to the conversion of NFA to DFA and finding the maximum number of states in an equivalent minimized DFA.

NFA to DFA Conversion:

- To convert NFA to DFA, we need to follow the subset construction algorithm. In this algorithm, we consider each state of the DFA as a set of NFA states.
- Initially, the start state of the DFA is the epsilon closure of the start state of the NFA.
- Then, for each input symbol, we find the set of states reachable from the current state of DFA by that input symbol. This set becomes the next state of the DFA.
- We repeat this process for all the states of the DFA until we get all the possible states.

Minimization of DFA:

- After converting NFA to DFA, we need to minimize the DFA to get an equivalent DFA with the minimum number of states.
- We use the state minimization algorithm to minimize the DFA. In this algorithm, we merge the states of the DFA which are equivalent, i.e., they have the same set of outgoing transitions for all input symbols.

Maximum Number of States in Minimized DFA:

- The maximum number of states in an equivalent minimized DFA can be found using the Myhill-Nerode theorem.
- According to this theorem, the number of states in a minimized DFA is at least equal to the number of distinct equivalence classes of strings in the language of the NFA.
- The number of distinct equivalence classes of strings in the language of the NFA is equal to 2^N, where N is the number of states in the NFA.
- Therefore, the maximum number of states in an equivalent minimized DFA is 2^N.

Conclusion:

Hence, we can conclude that the maximum number of states in an equivalent minimized DFA is at least 2^N.

Number of states of FSM required to simulate behaviour of a computer with a memory capable of storing “m” words, each of length ‘n’
  • a)
    m x 2n
  • b)
    2mn
  • c)
    2(m+n)
  • d)
    All of the mentioned
Correct answer is option 'B'. Can you explain this answer?

Rajeev Menon answered
For every Data here length is n and memory’s state is defined in terms of power of 2, Here the total memory capability for all the words = mn Hence the number of states is2^mn.

 For operator precedence parsing, which one is true?
  • a)
    For all pair of non-terminal
  • b)
    For all pair of terminals
  • c)
    To delimit the handle
  • d)
    None of the mentioned
Correct answer is option 'A'. Can you explain this answer?

Partho Joshi answered
There are two important properties for these operator precedence parsers is that it does not appear on the right side of any production and no production has two adjacent non-terminals. Implying that no production right side is empty or has two adjacent non-terminals. So accordingly to property option (A) is correct.

If ∑ = {a, b, c, d, e, f} then number of strings in ∑ of length 4 such that no symbol is used more than once in a string is
  • a)
    35
  • b)
    360
  • c)
    49
  • d)
    720
Correct answer is option 'B'. Can you explain this answer?

Explanation: Here string length is 4 so we create string of length 4 by 6 values firstly we arrange any value by 6 methods. Then Remaining numbers are 5 so we can arrange them by 5 methods then remaining numbers are 4 so we arrange them by 4 methods and then 3.Thus 6*5*4*3=360.

 Which of the following is right?
  • a)
    A Context free language can be accepted by a deterministic PDA
  • b)
    union of 2 CFLs is context free
  • c)
    The intersection of two CFLs is context free
  • d)
    The complement of CFLs is context free
Correct answer is option 'B'. Can you explain this answer?

Rohan Patel answered
Explanation:
Context-free languages (CFLs) are a type of formal language that can be generated by a context-free grammar (CFG). A deterministic pushdown automaton (DPDA) is a type of automaton that can recognize a context-free language.

a) A Context-free language can be accepted by a deterministic PDA
This statement is true. A DPDA can recognize a context-free language by pushing and popping symbols onto a stack based on the rules of a CFG.

b) Union of 2 CFLs is context free
This statement is true. If we have two CFLs, we can construct a CFG that generates their union. We can do this by taking the union of the two CFGs and adding a new start symbol that derives the start symbols of the original CFGs.

c) The intersection of two CFLs is context free
This statement is false. The intersection of two CFLs may not be a CFL. There may be no CFG that generates the intersection of the two CFLs.

d) The complement of CFLs is context free
This statement is false. The complement of a CFL may not be a CFL. There may be no CFG that generates the complement of the CFL.

Therefore, the correct answer is option 'B'.

Which one of the following statement is FALSE?
  • a)
    Context-free languages are closed under union
  • b)
    Context-free languages are closed under concatenation
  • c)
    Context-free languages are closed under intersection
  • d)
    Context-free languages are closed under Kleene closure
Correct answer is option 'C'. Can you explain this answer?

Surbhi Kaur answered
he FALSE statement is:
3. Context-free languages are closed under intersection.
Explanation:
  • Context-free languages (CFLs) are closed under:
    • Union: If L1L_1L1​ and L2L_2L2​ are CFLs, L1∪L2L_1 \cup L_2L1​∪L2​ is also a CFL.
    • Concatenation: If L1L_1L1​ and L2L_2L2​ are CFLs, L1⋅L2L_1 \cdot L_2L1​⋅L2​ (concatenation) is also a CFL.
    • Kleene closure: If LLL is a CFL, the Kleene closure (repetition) of LLL, denoted as L∗L^*L∗, is also a CFL.
However, CFLs are not closed under intersection. The intersection of two context-free languages is not necessarily a context-free language. In fact, the intersection of two CFLs may result in a language that is not context-free.

Which grammar defines Lexical Syntax
  • a)
    Regular Grammar
  • b)
    Syntactic Grammar
  • c)
    Context free Grammar
  • d)
    Lexical Grammar
Correct answer is option 'D'. Can you explain this answer?

The specification of a programming language often includes a set of rules, the lexical grammar, which defines the lexical syntax.

A system program that brings together separately compiled modules of a program into a form language that is suitable for execution
  • a)
    Assembler
  • b)
    Linking loader
  • c)
    Cross compiler
  • d)
    None of the mentioned
Correct answer is option 'B'. Can you explain this answer?

Nishanth Roy answered
Explanation: A loader which brings together the functions of a relocating loader with the ability to combine a number of program segments that have been independently compiled into an executable program.

An FSM with
  • a)
    M can be transformed to Numeral relabeling its states
  • b)
    M can be transformed to N, merely relabeling its edges
  • c)
    Both of the mentioned
  • d)
    None of the mentioned
Correct answer is option 'C'. Can you explain this answer?

A finite-state machine (FSM) or finite-state automaton (FSA, plural: automata), finite automaton, or simply a state machine, is a mathematical model of computation. ... An FSM is defined by a list of its states, its initial state, and the conditions for each transition.

Chapter doubts & questions for Lexical Analysis - Compiler Design 2025 is part of Computer Science Engineering (CSE) exam preparation. The chapters have been prepared according to the Computer Science Engineering (CSE) exam syllabus. The Chapter doubts & questions, notes, tests & MCQs are made for Computer Science Engineering (CSE) 2025 Exam. Find important definitions, questions, notes, meanings, examples, exercises, MCQs and online tests here.

Chapter doubts & questions of Lexical Analysis - Compiler Design in English & Hindi are available as part of Computer Science Engineering (CSE) exam. Download more important topics, notes, lectures and mock test series for Computer Science Engineering (CSE) Exam by signing up for free.

Compiler Design

26 videos|83 docs|30 tests

Top Courses Computer Science Engineering (CSE)