Explore topic-wise InterviewSolutions in .

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.

51.

A ________ is a string of characters which form a syntactic unit.(a) Lexeme(b) Lex(c) Lexeme & Lex(d) None of the mentionedThe question was posed to me in final exam.Query is from Lexical Analyser in chapter Finite Automata and Regular Expression of Compiler

Answer»

The CORRECT answer is (a) LEXEME

The EXPLANATION is: A lexeme is a STRING of characters that form a syntactic UNIT.

52.

Regular expressions are used to represent which language?(a) Recursive language(b) Context free language(c) Regular language(d) All of the mentionedI had been asked this question in class test.My question is based upon Obtaining the regular Expression from the Finite automata in chapter Finite Automata and Regular Expression of Compiler

Answer» CORRECT choice is (c) REGULAR language

To explain: Regular EXPRESSION is REPRESENTED by regular language.
53.

The process of forming tokens from an input stream of characters is called __________(a) Liberalisation(b) Characterisation(c) Tokenization(d) None of the mentionedThis question was addressed to me during a job interview.This is a very interesting question from Lexical Analyser in division Finite Automata and Regular Expression of Compiler

Answer»

The correct option is (c) TOKENIZATION

The best explanation: The PROCESS of forming tokens from an input stream of CHARACTERS is called tokenization.

54.

Which of the following regular expression denotes zero or more instances of an a or b?(a) a/b(b) (a/b)*(c) (ab)*(d) a*IbThis question was posed to me by my college professor while I was bunking the class.My doubt stems from Obtaining the regular Expression from the Finite automata topic in portion Finite Automata and Regular Expression of Compiler

Answer» CORRECT ANSWER is (B) (a/b)*

Easiest explanation: This expression gives o or more INSTANCES of a or b.
55.

Which one is a type of Lexeme?(a) Identifiers(b) Constants(c) Keywords(d) All of the mentionedThis question was posed to me in homework.Query is from Lexical Analyser topic in chapter Finite Automata and Regular Expression of Compiler

Answer»

The correct ANSWER is (d) All of the mentioned

The best EXPLANATION: All of them along with OPERATORS are different TYPES of LEXEMES.

56.

W hat is the complement of the language accepted by the NFA shown below?(a) A,B(b) B(c) C(d) D,CThis question was posed to me in an internship interview.Question is taken from Minimization of DFA in chapter Finite Automata and Regular Expression of Compiler

Answer»

The CORRECT OPTION is (B) B

The explanation is: The GIVEN alphabet contains only one SYMBOL {a} and the given NFA accepts all strings with any number of occurrences of ‘a’.

57.

_________ a phase of a compiler that maps the IR program into the instruction set and the finite resources of the target machine.(a) Optimizer(b) Parser(c) Optimizer & Parser(d) None of the mentionedThis question was posed to me in an international level competition.I'm obligated to ask this question of The NFA with epsilon-moves to the DFA-2 in division Finite Automata and Regular Expression of Compiler

Answer»

Correct answer is (d) None of the mentioned

For explanation I would say: In a two-phase COMPILER, ensures that there is a SOURCE PROGRAM and an OBJECT program.

58.

Let L1 = {w ∈ {0,1}∗ | w has at least as many occurrences of (110)’s as (011)’s}.Let L2 = { ∈ {0,1}∗ | w has at least as many occurrences of (000)’s as (111)’s}.Which one of the following is TRUE?(a) L1 is regular but not L2(b) L2 is regular(c) L1 and L2 are regular(d) Neither of them are regularThis question was addressed to me at a job interview.My query is from Minimization of DFA topic in portion Finite Automata and Regular Expression of Compiler

Answer»

Right choice is (a) L1 is regular but not L2

The best EXPLANATION: L1 is regular let us considering the string 011011011011 . Number of times 011 has occurred is 4but also its occurrence is 3. Also if the string is ending with 011we can make a 110 . Now the next string: 110110110110 in this 110 has occurred 4 times and 011 3 times which already satisfy the .

59.

In a compiler the module that checks every character of the source text is called __________(a) The code generator(b) The code optimizer(c) The lexical analyzer(d) The syntax analyzerThis question was posed to me during an online exam.Asked question is from Lexical Analyser topic in chapter Finite Automata and Regular Expression of Compiler

Answer»

The correct ANSWER is (a) The code generator

Explanation: LEXICAL ANALYSIS is the process of converting a sequence of CHARACTERS into a sequence of tokens.

60.

The set of all strings over ∑ = {a,b} in which all strings having bbbb as substring is?(a) (a+b)* bbbb (a+b)*(b) (a+b)* bb (a+b)*bb(c) bbb(a+b)*(d) bb (a+b)*This question was posed to me in class test.This interesting question is from Obtaining the regular Expression from the Finite automata in chapter Finite Automata and Regular Expression of Compiler

Answer»

The CORRECT OPTION is (a) (a+b)* bbbb (a+b)*

To explain: Out ofall RE MENTIONED only the first stringcertainly has bbbb as SUBSTRING. Rest all just have a possibility of having it.

61.

Given an arbitrary non-deterministic finite automaton (NFA) with N states, the maximum number of states in an equivalent minimized DFA is at least?(a) N^2(b) 2^N(c) 2N(d) N!This question was addressed to me during an internship interview.The above asked question is from Obtaining the regular Expression from the Finite automata in portion Finite Automata and Regular Expression of Compiler

Answer»

Correct OPTION is (C) 2N

For explanation I would say: If the NFA has n states, the resulting DFA may have up to 2n states, an exponentially larger number, which sometimes makes the CONSTRUCTION IMPRACTICAL for large NFAs.

62.

__________ a part of a compiler that takes as input a stream of characters and produces as output a stream of words along with their associated syntactic categories.(a) Parser(b) Optimizer(c) Scanner(d) None of the mentionedThis question was addressed to me at a job interview.My enquiry is from The NFA with epsilon-moves to the DFA-2 in section Finite Automata and Regular Expression of Compiler

Answer»

Correct choice is (C) SCANNER

Explanation: A compiler’s scanner reads an INPUT stream that consists of characters and produces an OUTPUT stream that contains words, each labelled with its Syntactic category.

63.

L1 is accepted by the NFA, obtained by changing the accepting state of M to a non-accepting state and vice versa. Which of the following statements is true?(a) L1 = {0, 1}* – L(b) L1 = {0, 1}* – L(c) L1 ⊆ L(d) L1=LI got this question by my college director while I was bunking the class.This intriguing question comes from Obtaining the regular Expression from the Finite automata topic in chapter Finite Automata and Regular Expression of Compiler

Answer»

Correct answer is (b) L1 = {0, 1}* – L

For explanation I WOULD say: Either it TAKES 0 or 1 or iterations of it or none.compilers-questions-answers-Obtaining the regular Expression from the FINITE autom

64.

The grammar G: S → SS | a | b is ambiguous. Check all and only the strings that have exactly two leftmost derivations in G.(a) bbb(b) ab(c) All of the mentioned(d) None of the mentionedThis question was addressed to me by my college director while I was bunking the class.The above asked question is from The NFA with n-moves to the DFA topic in division Finite Automata and Regular Expression of Compiler

Answer»

Correct CHOICE is (C) All of the mentioned

To elaborate: S => a. A string of length 2 has only one DERIVATION, e.g., S => SS => aS => ab.

65.

An NFA is nothing more than an ε-NFA with no ε transitions.(a) True(b) FalseThis question was addressed to me by my school teacher while I was bunking the class.My query is from The NFA with epsilon-moves to the DFA-2 topic in chapter Finite Automata and Regular Expression of Compiler

Answer»

The CORRECT answer is (a) True

Easiest EXPLANATION: An NFA is NOTHING more than an ε-NFA with no ε TRANSITIONS. Thus • δ (q, ε) for all STATES q = ∅.

66.

_________an IR-to-IR transformer that tries to improve the IR program in some way.(a) Optimizer(b) Parser(c) All of the mentioned(d) None of the mentionedThis question was posed to me in homework.I'm obligated to ask this question of The NFA with epsilon-moves to the DFA-2 topic in division Finite Automata and Regular Expression of Compiler

Answer»

Right answer is (a) Optimizer

For EXPLANATION: The optimizer is an IR-to-IR TRANSFORMER that tries to IMPROVE the IR program in some WAY.

67.

NFA-εs are defined because certain properties can be more easily proved on them as compared to NFA.(a) True(b) FalseThis question was addressed to me by my school teacher while I was bunking the class.Question is from The NFA with epsilon in chapter Finite Automata and Regular Expression of Compiler

Answer»

The correct choice is (a) True

The explanation is: NFA-ε can be transformed into a NFA ALWAYS, the PROPERTIES are ALSO true for NFAs.

68.

For every NFA a deterministic finite automaton (DFA) can be found that accepts the same language.(a) True(b) FalseThis question was posed to me in an interview.My doubt is from Non-Deterministic Finite Automata in portion Finite Automata and Regular Expression of Compiler

Answer»

The correct choice is (a) True

To explain I would SAY: Therefore it is possible to convert an existing NFA into a DFA for the PURPOSE of implementing a simpler machine. Which is executed by using the POWERSET construction.

69.

Which is the application of NFA?(a) A regular language is produced by union of two regular languages(b) The concatenation of two regular languages is regular(c) The Kleene closure of a regular language is regular(d) All of the mentionedThe question was asked in an international level competition.Origin of the question is Non-Deterministic Finite Automata in chapter Finite Automata and Regular Expression of Compiler

Answer» RIGHT ANSWER is (d) All of the mentioned

Easiest EXPLANATION: As PER its DEFINITION.
70.

Which of the following statement is true for Moore Machine?(a) Output depends on present state(b) Output depends on present input(c) Output depends on present state and present input(d) Output depends on present state and past inputThis question was addressed to me in a job interview.This key question is from Finite Automata topic in chapter Finite Automata and Regular Expression of Compiler

Answer» CORRECT choice is (a) Output depends on present STATE

The best I can explain: The DEFINITION STATES that moore machines output is determined by the CURRENT state only.
71.

Which of the following is a correct statement?(a) { If an bn| n = 0,1, 2, 3 ..} is regular language(b) Strings with equal number of a’s and b’s denies a regular language(c) L (A* B*)∩ B gives the set A(d) None of the mentionedI had been asked this question during an interview.This intriguing question comes from The NFA with epsilon topic in section Finite Automata and Regular Expression of Compiler

Answer» RIGHT option is (c) L (A* B*)∩ B gives the set A

Best explanation: If we include A and B in a set and if we write A*it means exceptthen A i.e. Bsame asB*means EXCEPT then B i.e. so if we INTERSECT (A*B*)and Bthen get Abecause in any regular language. If we write A-B then A-B=A intersection B’so if we intersect A and B means A-BSo the intersection of (A*B*) and B= (BA). intersection Bmeans (BA)-B’ and B’=A so (BA) intersection(A)=A.
72.

S –> aSa| bSb| a| b; the language generated by the above grammar is the set of ____________(a) All palindromes(b) All odd length palindromes(c) Strings beginning and ending with the same symbol(d) All even length palindromesThis question was posed to me by my college director while I was bunking the class.Enquiry is from The NFA with epsilon in section Finite Automata and Regular Expression of Compiler

Answer»

The correct choice is (b) All odd length PALINDROMES

The best EXPLANATION: The STRINGS accepted by language are {a, b, aaa, BBB, ABA, bab,}. All the strings are odd length palindromes.

73.

A regular language corresponds to __________(a) An alphabet(b) Set of strings over an alphabet(c) A DFA only(d) A DFA or an NFAThe question was posed to me in a national level competition.Question is taken from Non-Deterministic Finite Automata topic in section Finite Automata and Regular Expression of Compiler

Answer» RIGHT ANSWER is (B) Set of STRINGS over an alphabet

To EXPLAIN: A regular grammar takes in all strings over an alphabet.
74.

The string WWR is not recognized by any FSM because _____________(a) An FSM cannot remember arbitrarily large amount of information(b) An FSM cannot fix the midpoint(c) An FSM cannot match W with WR(d) An FSM cannot remember first and last inputsI have been asked this question in exam.Query is from Finite Automata in chapter Finite Automata and Regular Expression of Compiler

Answer»

The correct CHOICE is (b) An FSM cannot FIX the midpoint

To elaborate: Palindromes cannot be RECOGNIZED by FSM.

75.

What is the transitional function of an NFA?(a) Q X Σ→Q(b) Q X Σ→2Q(c) Q X Σ→2n(d) Q X Σ→QnI got this question during an online exam.This interesting question is from Finite Automata in division Finite Automata and Regular Expression of Compiler

Answer»

The correct option is (b) Q X Σ→2Q

To EXPLAIN: Let Q be a FINITE SET and let be a finite set of symbols. Also let be a function from Q to 2Q. All the elements of Q a state, the transition function, q0 the initial state and A the set of accepting states.

Then a nondeterministic finite automaton is a 5-tuple < Q,, q0,, A >.

76.

Does epsilon ring any change in the automata.(a) Yes(b) NoThis question was addressed to me during an online interview.My query is from The NFA with epsilon topic in chapter Finite Automata and Regular Expression of Compiler

Answer»

Correct CHOICE is (B) No

The explanation is: It adds NOTHING NEW to the automata.

77.

Which behaviour of a NFA can be stimulated by DFA?(a) Always(b) Sometimes(c) Never(d) Depends on NFAThe question was posed to me in final exam.This interesting question is from Transformation from NFA to DFA in division Finite Automata and Regular Expression of Compiler

Answer» CORRECT choice is (a) Always

For explanation: It can be DONE through POWER set CONSTRUCTION.
78.

Is an ordinary NFA and a NFA-ε are equivalent.(a) True(b) FalseI have been asked this question in an interview for job.My doubt stems from The NFA with epsilon topic in division Finite Automata and Regular Expression of Compiler

Answer»

Right choice is (a) True

Easiest explanation: YES ordinary NFA and NFA-ε are the same, in that, given either one, one can CONSTRUCT the other, which recognizes the same LANGUAGE.

79.

Find the wrong statement?(a) The language accepted by finite automata are the languages denoted by regular expression(b) Every DFA has a regular expression denoting its language(c) For a regular expression r, there does not exists NDFA with L® ant transit that accept(d) None of the mentionedI have been asked this question during a job interview.My enquiry is from Transformation from NFA to DFA topic in section Finite Automata and Regular Expression of Compiler

Answer»

Correct OPTION is (c) For a regular expression R, there does not EXISTS NDFA with L® ant transit that accept

To explain I would SAY: The vice versa is TRUE.

80.

Conversion of a DFA to an NFA __________(a) Is impossible(b) Requires the subset construction(c) Is Chancy(d) Is nondeterministicI have been asked this question at a job interview.I would like to ask this question from Non-Deterministic Finite Automata topic in section Finite Automata and Regular Expression of Compiler

Answer»

The CORRECT option is (B) Requires the subset construction

To explain I would SAY: In order to convert NDFA to DFA we work with sets of state where each state in the DFA corresponds to a set of NFA states.

81.

Which type of string is accepted by the following finite automata?(a) All string(b) Null string(c) No string(d) None of the mentionedThe question was posed to me in an interview.My doubt stems from Finite Automata topic in chapter Finite Automata and Regular Expression of Compiler

Answer»

Right answer is (b) NULL string

To ELABORATE: Null STRINGS are not accepted by FINITE AUTOMATA.

82.

The regular languages are not closed under ___________(a) Concatenation(b) Union(c) Kleene star(d) ComplementThis question was addressed to me in a job interview.My question is based upon Non-Deterministic Finite Automata topic in chapter Finite Automata and Regular Expression of Compiler

Answer»

Correct choice is (d) Complement

Easiest EXPLANATION: Explanation: RE are CLOSED under

Union (CF. picture)

Intersection

Concatenation

Negation

Kleene CLOSURE.

83.

Which of the following statement is true for Mealy Machine?(a) Output depends on present state(b) Output depends on present input(c) Output depends on present state and present input(d) Output depends on present state and past inputI got this question in semester exam.My question is taken from Finite Automata in portion Finite Automata and Regular Expression of Compiler

Answer»

Right OPTION is (c) OUTPUT depends on PRESENT state and present input

Easy explanation: The definition states that its output is DETERMINED by current state and current input.

84.

The Tuples for NDFA is ___________(a) ∑, Q, q0, F, δ(b) Q, q0, F, δ(c) Θ, Q, q0, F,δ(d) F, Q, Δ, q0, δThis question was addressed to me during an interview.I need to ask this question from Non-Deterministic Finite Automata in section Finite Automata and Regular Expression of Compiler

Answer»

Correct ANSWER is (a) ∑, Q, q0, F, δ

The explanation: An NFA is represented formally by a 5-tuple, (Q, Σ, Δ, q0, F), of

aset of STATES Q

a set of INPUT symbols Σ

a transition function Δ : Q × Σ → P(Q).

an initial state q0 ∈ Q

afinal state F ⊆ Q.

85.

Which is true for in accessible state?(a) It cannot be reached anytime(b) There is no necessity of the state(c) If control enters no way to come out from the state(d) If control enters FA deadsI got this question in my homework.Question is from Finite Automata in portion Finite Automata and Regular Expression of Compiler

Answer»

The correct ANSWER is (a) It cannot be REACHED anytime

Explanation: The very MEANING of in accessible state is that it cannot be reached at any POINT of TIME.

86.

Which one is a FALSE statement?(a) There exists a unique DFA for every regular language(b) NFA can always are converted to a PDA(c) Complement of CFL is always recursive(d) Every NDFA can be converted to a DFAI got this question in quiz.The doubt is from The NFA with epsilon topic in division Finite Automata and Regular Expression of Compiler

Answer» RIGHT answer is (d) Every NDFA can be converted to a DFA

Easy explanation: Deterministic PDA cannot handle languages or GRAMMARS with ambiguity, but NDFA can handle with ambiguous languages as well as context-free grammar. Hence not every Ndfa can be converted to DFA.
87.

For any DFA state {qi,qj…qm} If some qj is a final state in the NFA Then {qi,qj…qm}, is a final state in the DFA.(a) True(b) FalseThis question was posed to me in semester exam.Origin of the question is Transformation from NFA to DFA in portion Finite Automata and Regular Expression of Compiler

Answer» CORRECT CHOICE is (a) True

Explanation: It the standard procedure to CONVERT NFA to DFA.
88.

Is empty string a valid input in Ndfa.(a) True(b) FalseThis question was posed to me in an online quiz.This key question is from Transformation from NFA to DFA in division Finite Automata and Regular Expression of Compiler

Answer»

The CORRECT CHOICE is (a) True

The EXPLANATION is: Empty strings can be inputted n a NDFA.

89.

Which of the following CFG’s can’t be simulated by an FSM?(a) S->Sa/b(b) S->aSb/ab(c) S->abX, X->cY, Y->d/aX(d) None of the mentionedThe question was asked in an online quiz.This interesting question is from The NFA with epsilon in division Finite Automata and Regular Expression of Compiler

Answer»

Correct CHOICE is (b) S->aSb/ab

For explanation I would SAY: generates the set {an BN, n=1,2,3 ….}which is not REGULAR.

90.

E(q) is known ε-closure of q.(a) True(b) FalseThis question was posed to me by my school teacher while I was bunking the class.I want to ask this question from The NFA with epsilon in division Finite Automata and Regular Expression of Compiler

Answer»

Right answer is (a) True

For EXPLANATION I WOULD SAY: The ε-closure of a set of states Z of an NFA is defined as the set of states reachable from any state in Z following ε-transitions.

91.

Regular expression a/b denotes which of the following set?(a) {a}(b) {€,a,b}(c) {a,b}(d) {ab}The question was asked by my college professor while I was bunking the class.Asked question is from Transformation from NFA to DFA topic in chapter Finite Automata and Regular Expression of Compiler

Answer»

The CORRECT answer is (C) {a,b}

The explanation: EITHER a is the output or b HENCE it’s {a, b}.

92.

A language L from a grammar G = { VN, Σ, P, S} is?(a) Set of symbols over VN(b) Set of symbols over Σ(c) Set of symbols over P(d) Set of symbols over SThe question was posed to me in an online quiz.Enquiry is from Finite Automata in chapter Finite Automata and Regular Expression of Compiler

Answer»

Right CHOICE is (b) SET of SYMBOLS over Σ

Easiest explanation: The definition of the GRAMMAR is set of symbols over Σ.

93.

Which of the following statement is true for Dead State?(a) It cannot be reached anytime(b) There is no necessity of the state(c) If control enters no way to come out from the state(d) If control enters FA deadsThe question was asked by my college professor while I was bunking the class.My question is taken from Finite Automata topic in section Finite Automata and Regular Expression of Compiler

Answer»

Right choice is (c) If control enters no way to come out from the STATE

To elaborate: It is a rejecting state for if the control enters it REACHES the DEAD end and cannot REACH an accepting state.

94.

Myhill-Nerode Theorem is used for __________(a) Minimization of DFA(b) Maximization of NFA(c) Conversion of NFA(d) Conversion of DFAThis question was posed to me in an interview.My question comes from Finite Automata in division Finite Automata and Regular Expression of Compiler

Answer»

Correct choice is (a) MINIMIZATION of DFA

The best I can EXPLAIN: Myhill–Nerode theorem PROVIDES a necessary and sufficient condition for a LANGUAGE to be regular. The Myhill–Nerode theorem can be generalized to trees. And used for minimization of DFA.

95.

A nondeterministic finite automation with ε-moves is an extension of nondeterministic finite automation.(a) True(b) FalseI got this question by my college professor while I was bunking the class.I need to ask this question from The NFA with epsilon topic in chapter Finite Automata and Regular Expression of Compiler

Answer» RIGHT ANSWER is (a) True

To ELABORATE: Both are EQUIVALENT.
96.

In Mealy Machine O/P is associated with ____________(a) Present state(b) Next state(c) Input(d) None of the mentionedI had been asked this question in my homework.I need to ask this question from Finite Automata in portion Finite Automata and Regular Expression of Compiler

Answer»

Correct ANSWER is (b) NEXT state

Easiest EXPLANATION: The definition states that its output is DETERMINED by current state and current INPUT.

97.

The transitions which does not take an input symbol are called ___________(a) ε-transitions(b) λ-transitions(c) ε-transitions & λ-transitions(d) none of the mentionedI got this question in my homework.My question comes from The NFA with epsilon topic in division Finite Automata and Regular Expression of Compiler

Answer» CORRECT answer is (c) ε-transitions & λ-transitions

Easy EXPLANATION: The transitions TAKING an INPUT symbol are called ε-transitions or λ-transitions.
98.

A finite automata recognizes ____________(a) Any Language(b) Context Sensitive Language(c) Context Free Language(d) Regular LanguageThis question was posed to me in an internship interview.My doubt is from Finite Automata in division Finite Automata and Regular Expression of Compiler

Answer»

Correct option is (d) Regular Language

Best EXPLANATION: All regular languages are IMPLEMENTED by FINITE AUTOMATA.

99.

What is the relation between NFA-accepted languages and DFA accepted languages?(a) >(b)

Answer»

The correct OPTION is (c) =

To elaborate: The no of LANGUAGES accepted by NFA and DFA is EQUAL.

100.

The definition of a language L with alphabet {a} is given as following. L = { ank | k > 0, and n is a positive integer constant} What is the minimum number of states needed in a DFA to recognize L?(a) k+1(b) n+1(c) 2n+1(d) 2k+1I have been asked this question during an interview for a job.This intriguing question comes from Transformation from NFA to DFA topic in division Finite Automata and Regular Expression of Compiler

Answer» CORRECT CHOICE is (b) N+1

To explain I would SAY: NOTE that n is a constant and k is any positive integer. For example, let n=3, then the DFA must be able to accept aaa, aaaaaa, aaaaaaaaa, , .. build such a DFA, 4 states are required.