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.

It is suitable to use ____________ method/methods to convert a DFA to regular expression.(a) Transitive Closure properties(b) Brzozowski method(c) State elimination method(d) All of the mentionedI have been asked this question in a job interview.I'm obligated to ask this question of Conversion by Eliminating states in division Regular Expressions and Languages of Automata Theory

Answer»

The correct ANSWER is (d) All of the mentioned

For EXPLANATION: For converting RE to DFA , FIRST we convert RE to NFA (Thompson CONSTRUCTION), and then NFA is converted into DFA(Subset Construction).

52.

A finite automaton accepts which type of language:(a) Type 0(b) Type 1(c) Type 2(d) Type 3This question was addressed to me in my homework.This intriguing question originated from Operators of Regular Expression in division Regular Expressions and Languages of Automata Theory

Answer» CORRECT choice is (d) TYPE 3

The best I can explain: Type 3 refers to Regular Languages which is accepted by a FINITE AUTOMATON.
53.

Concatenation of R with Ф outputs:(a) R(b) Ф(c) R.Ф(d) None of the mentionedThe question was posed to me by my college director while I was bunking the class.My doubt is from Regular Expression-Introduction in portion Regular Expressions and Languages of Automata Theory

Answer»

Correct option is (b) Ф

Easiest explanation: By DISTRIBUTIVE PROPERTY (REGULAR expression identities), we can prove the given identity to be Ф.

54.

Which of the technique can be used to prove that a language is non regular?(a) Ardens theorem(b) Pumping Lemma(c) Ogden’s Lemma(d) None of the mentionedI have been asked this question in an interview.This interesting question is from Properties-Non Regular Languages in section Regular Expressions and Languages of Automata Theory

Answer»

Right option is (b) Pumping Lemma

To EXPLAIN: We use the POWERFUL technique called Pumping Lemma, for showing certain languages not to be REGULAR. We use ARDENS theorem to find out a regular expression out of a finite AUTOMATON.

55.

Which among the following is not a tool to construct lexical analyzer from a regular expression?(a) lex(b) flex(c) jflex(d) none of the mentionedThis question was addressed to me in an interview for job.This is a very interesting question from Lexical Analysis in chapter Regular Expressions and Languages of Automata Theory

Answer»

Correct answer is (d) none of the mentioned

Best EXPLANATION: Lexical analysis is done using few tools such as lex, flex and jflex. Jflex is a computer PROGRAM that GENERATES lexical analyzers (ALSO known as lexers or scanners) and works apparently like lex and flex. Lex is commonly USED with yacc parser generator.

56.

Let the class of language accepted by finite state machine be L1 and the class of languages represented by regular expressions be L2 then(a) L1=L2(c) L1 U L2 = .*(d) L1=L2This question was posed to me in an internship interview.My question is based upon Regular Language & Expression in chapter Regular Expressions and Languages of Automata Theory

Answer»

Correct answer is (d) L1=L2

The EXPLANATION is: FINITE STATE machine and REGULAR expression have same power to express a language.

57.

What does grep do in UNIX?(a) It is an editor in UNIX(b) It searches for text patterns(c) Both (a) and (b)(d) None of the mentionedI had been asked this question by my school principal while I was bunking the class.My question comes from Regular Expression in UNIX topic in division Regular Expressions and Languages of Automata Theory

Answer»

Right answer is (b) It searches for text patterns

The explanation: The grep is a STANDARD UNIX utility PROGRAM that searches through a set of files in search of a text pattern,specified through a REGULAR expression.

58.

Which among the following is not a UNIX command for regular expressions?(a) ed(b) sed(c) vi(d) none of the mentionedI had been asked this question in an international level competition.The query is from Regular Expression in UNIX in chapter Regular Expressions and Languages of Automata Theory

Answer»

The correct choice is (d) NONE of the mentioned

To explain: Regular expressions are USED by different commands in UNIX like ed, sed, grep, awk, vi, ETC. Sed stands for stream editor which is exclusively used for executing SCRIPTS.

59.

Which of the following is true?(a) (01)*0 = 0(10)*(b) (0+1)*0(0+1)*1(0+1) = (0+1)*01(0+1)*(c) (0+1)*01(0+1)*+1*0* = (0+1)*(d) All of the mentionedI got this question in exam.The question is from Regular Language & Expression topic in section Regular Expressions and Languages of Automata Theory

Answer»

The CORRECT ANSWER is (d) All of the mentioned

The EXPLANATION is: NONE.

60.

(a+b)* is equivalent to(a) b*a*(b) (a*b*)*(c) a*b*(d) none of the mentionedThis question was addressed to me in exam.The origin of the question is Regular Language & Expression topic in section Regular Expressions and Languages of Automata Theory

Answer»

Right CHOICE is (B) (a*b*)*

For EXPLANATION I would say: NONE.

61.

Regular expression {0,1} is equivalent to(a) 0 U 1(b) 0 / 1(c) 0 + 1(d) All of the mentionedThe question was posed to me in exam.I would like to ask this question from Regular Language & Expression in division Regular Expressions and Languages of Automata Theory

Answer»

The correct ANSWER is (d) All of the mentioned

Easiest EXPLANATION: All are EQUIVALENT to union operation.

62.

Generate a regular expression for the given language:lL(x): {xÎ{0,1}*| x ends with 1 nd does not contain a substring 01}(a) (0+01)*(b) (0+01)*1(c) (0+01)*(1+01)(d) All of the mentionedThis question was posed to me by my college director while I was bunking the class.The query is from DFA to Regular Expressions in portion Regular Expressions and Languages of Automata Theory

Answer»

Right option is (C) (0+01)*(1+01)

To explain I would SAY: (a) and (b) are the general cases where we restrict the acceptance of a string witrh substring 00 but we ignore the case where the string needs to end with 1 which therby, does not allows the acceptance of e.

63.

State true or false:Statement: A regular expression is a sequence of characters that represent a pattern.(a) Statement: A regular expression is a sequence of characters that represent a pattern.(b) true(c) falseI got this question by my school teacher while I was bunking the class.My question comes from Regular Expression in UNIX topic in section Regular Expressions and Languages of Automata Theory

Answer»

Correct CHOICE is (a) Statement: A regular EXPRESSION is a sequence of characters that represent a pattern.

Easiest explanation: Such a generated pattern COULD be a FIXED WORD or describe something like more general.

64.

Statement: A digit, when used in the CFG notation, will always be used as a terminal.(a) State true or false?(b) True(c) FalseI had been asked this question by my school teacher while I was bunking the class.My query is from Finding Patterns in Text,Algebric Laws and Derivatives in portion Regular Expressions and Languages of Automata Theory

Answer»

Correct CHOICE is (a) State true or false?

To explain I would say: Lowercase letters NEAR the beginning of an ALPHABET, a, B and so on are terminal symbols. We shall also assume that digits and other characters such as + or parenthesis are TERMINALS.

65.

The following is/are an approach to process a regexp:(a) Contruction of NFA and subsequently, a DFA.(b) Thompson’s Contruction Algorithm(c) Both (a) and (b)(d) None of the mentionedThe question was posed to me in homework.My question is from Converting Regular Expressions to Automata topic in portion Regular Expressions and Languages of Automata Theory

Answer»

The CORRECT answer is (c) Both (a) and (b)

To elaborate: A regexp processor TRANSLATES the syntax into internal representation which can be executed and matched with a string and that internal representation can have SEVERAL approaches LIKE the ONES mentioned.

66.

Which of the following statements is not true?(a) Every language defined by any of the automata is also defined by a regular expression(b) Every language defined by a regular expression can be represented using a DFA(c) Every language defined by a regular expression can be represented using NFA with e moves(d) Regular expression is just another representation for any automata definitionThis question was addressed to me in exam.The query is from DFA to Regular Expressions topic in chapter Regular Expressions and Languages of Automata Theory

Answer»

Correct choice is (b) Every LANGUAGE defined by a REGULAR expression can be represented using a DFA

To ELABORATE: Using NFA with e moves, we can represent all the regular expressions as an automata. As regular expressions include e, we need to usee moves.

67.

L and ~L are recursive enumerable then L is(a) Regular(b) Context free(c) Context sensitive(d) RecursiveI had been asked this question in an interview.My query is from Regular Language & Expression in portion Regular Expressions and Languages of Automata Theory

Answer» CORRECT choice is (d) RECURSIVE

Explanation: If L is recursive ENUMERABLE and its COMPLEMENT too if and only if L is recursive.
68.

A language is regular if and only if(a) accepted by DFA(b) accepted by PDA(c) accepted by LBA(d) accepted by Turing machineI got this question by my college professor while I was bunking the class.I'd like to ask this question from Regular Language & Expression in section Regular Expressions and Languages of Automata Theory

Answer» RIGHT OPTION is (a) accepted by DFA

The explanation: All of above machine can accept regular LANGUAGE but all STRING accepted by machine is regular only for DFA.
69.

a? is equivalent to(a) a(b) a+Φ(c) a+ϵ(d) wrong expressionI had been asked this question by my school teacher while I was bunking the class.This is a very interesting question from Regular Language & Expression topic in portion Regular Expressions and Languages of Automata Theory

Answer» CORRECT OPTION is (c) a+ϵ

The BEST EXPLANATION: Zero or one time REPETITION of previous character .
70.

If R represents a regular language, which of the following represents the Venn-diagram most correctly?(a) An Irregular Set(b) R*(c) R complement(d) R reverseThis question was posed to me in an internship interview.Origin of the question is Regular Expression-Introduction in portion Regular Expressions and Languages of Automata Theory

Answer»

Correct option is (b) R*

The explanation: The given diagram represents the KLEENE operation over the REGULAR Language R in which the final states BECOME the initial and the initial state BECOMES final.

71.

Which of the following is the task of lexical analysis?(a) To build the uniform symbol table(b) To initialize the variables(c) To organize the variables in a lexical order(d) None of the mentionedThe question was asked in an online interview.My query is from Lexical Analysis topic in division Regular Expressions and Languages of Automata Theory

Answer»

The correct answer is (a) To build the UNIFORM symbol table

To explain I would SAY: Lexical analysis involves the following task:

a) Building a uniform symbol table

b) Parsing the SOURCE CODE into tokens

c) Building a literal and identifier table

72.

Concatenation Operation refers to which of the following set operations:(a) Union(b) Dot(c) Kleene(d) Two of the options are correctI had been asked this question during an online interview.My query is from Regular Expression-Introduction in chapter Regular Expressions and Languages of Automata Theory

Answer»

Correct option is (b) Dot

Explanation: TWO OPERANDS are SAID to be performing Concatenation operation AB = A•B = {xy: x ∈ A & y ∈ B}.

73.

Which of the following is an utility of state elimination phenomenon?(a) DFA to NFA(b) NFA to DFA(c) DFA to Regular Expression(d) All of the mentionedI had been asked this question in class test.The above asked question is from Conversion by Eliminating states in section Regular Expressions and Languages of Automata Theory

Answer»

The correct CHOICE is (c) DFA to Regular Expression

Explanation: We USE this algorithm to simplify a finite automaton to regular expression or vice versa. We ELIMINATE states while CONVERTING a given finite automata to its corresponding regular expression.

74.

The finite automata accept the following languages:(a) Context Free Languages(b) Context Sensitive Languages(c) Regular Languages(d) All the mentionedThis question was posed to me at a job interview.Question is taken from Building Regular Expressions in chapter Regular Expressions and Languages of Automata Theory

Answer»

The correct ANSWER is (c) Regular Languages

Easiest EXPLANATION: A FINITE automaton accepts the languages which are regular and for which a DFA can be constructed.

75.

Which of the following language regular?(a) {a^ib^i|i>=0}(b) {a^ib^i|0

Answer» RIGHT option is (b) {a^ib^i|0
For explanation: Here, i has limits i.e. the language is finite, contains few elements and can be GRAPHED USING a deterministic finite automata. THUS, it is regular. Others can be proved non regular using Pumping LEMMA.
76.

____________ is used for grouping up of characters into token.(a) Lexical Analyzer(b) oolex(c) jflex(d) All of the mentionedThis question was posed to me during an internship interview.My question comes from Lexical Analysis in portion Regular Expressions and Languages of Automata Theory

Answer»

The CORRECT option is (d) All of the mentioned

Explanation: oolex, flex, lex, jflex, all are lexical ANALYZER TOOLS which PERFORM the following function.

77.

What is the significance of (dollarSign) used in regular expression in UNIX?(a) Matches the beginning of the line(b) Matches the end of lines(c) Matches any single character(d) None of the mentionedI got this question during an internship interview.My doubt is from Regular Expression in UNIX in portion Regular Expressions and Languages of Automata Theory

Answer»

Correct OPTION is (b) Matches the end of lines

For explanation: Regular expression provides more flexibility while MATCHING string patterns. SPECIAL characters LIKE ^, $, *, . are very useful.

78.

Lexemes can be referred to as:(a) elements of lexicography(b) sequence of alphanumeric characters in a token(c) lexical errors(d) none of the mentionedI got this question by my school teacher while I was bunking the class.I want to ask this question from Lexical Analysis in division Regular Expressions and Languages of Automata Theory

Answer»

Right choice is (b) sequence of alphanumeric CHARACTERS in a TOKEN

Explanation: A LEXEME is a STRING of characters that form a syntactic unit. It is REASONABLE to say that is the sequence of alphanumeric characters in a token.

79.

How many strings of length less than 4 contains the language described by the regular expression (x+y)*y(a+ab)*?(a) 7(b) 10(c) 12(d) 11This question was addressed to me in an interview for job.My enquiry is from Regular Language & Expression in section Regular Expressions and Languages of Automata Theory

Answer»

Right answer is (c) 12

Explanation: string of length 0 = Not possible (because y is ALWAYS present).

string of length 1 = 1 (y)

string of length 2 = 3 (XY,YY,ya)

string of length 3 = 8 (XXY,xyy,yxy,yyy,YAA,yab,xya,yya)

80.

The given NFA represents which of the following NFA(a) (ab U a) *(b) (a*b* U a*)(c) (ab U a*)(d) (ab)* U a*I got this question in an online interview.The question is from Building Regular Expressions topic in portion Regular Expressions and Languages of Automata Theory

Answer»

Correct answer is (a) (ab U a) *

To EXPLAIN: The Regular expression (ab U a) * is converted to NFA in a SEQUENCE of stages as it can be CLEARLY SEEN in the diagram. This NFA consist of 8 stated while its minimized form only contains 2 states.

81.

State true or false:Statement: For every removed state, there is a regular expression produced.(a) true(b) falseThis question was posed to me in an interview for job.Origin of the question is Conversion by Eliminating states in chapter Regular Expressions and Languages of Automata Theory

Answer»

Correct answer is (a) true

Best explanation: For every state which is eliminated, a NEW regular EXPRESSION is produced. The NEWLY GENERATED regular expression act as an input for a state which is next to REMOVED state.

82.

Which of the following languages have built in regexps support?(a) Perl(b) Java(c) Python(d) C++I got this question during an online exam.This interesting question is from Converting Regular Expressions to Automata topic in portion Regular Expressions and Languages of Automata Theory

Answer»

Correct choice is (a) Perl

The explanation is: Many languages COME with built in support of REGEXPS like Perl, Javascript, Ruby ETC. While some provide support using STANDARD LIBRARIES like .NET, Java, Python, C++, C and POSIX.

83.

What kind of expressions do we used for pattern matching?(a) Regular Expression(b) Rational Expression(c) Regular & Rational Expression(d) None of the mentionedI have been asked this question in an interview for job.This question is from Converting Regular Expressions to Automata in section Regular Expressions and Languages of Automata Theory

Answer»

The correct answer is (c) Regular & RATIONAL Expression

For explanation I would say: In automata theory, Regular Expression(SOMETIMES also called the Rational Expression) is a SEQUENCE or set of CHARACTERS that define a search pattern, mainly for the use in pattern matching with strings or string matching.

84.

Regular Expression R and the language it describes can be represented as:(a) R, R(L)(b) L(R), R(L)(c) R, L(R)(d) All of the mentionedI have been asked this question in class test.Origin of the question is Building Regular Expressions topic in chapter Regular Expressions and Languages of Automata Theory

Answer»

Right OPTION is (c) R, L(R)

The best EXPLANATION: When we WISH to distinguish between a REGULAR expression R and the language it represents; we write L(R) to be the language of R.

85.

According to the precedence rules, x-y-z is equivalent to which of the following?(a) (x-y)-z(b) x-(y-z)(c) Both (x-y)-z and x-(y-z)(d) None of the mentionedThis question was addressed to me in an internship interview.My query is from Building Regular Expressions in portion Regular Expressions and Languages of Automata Theory

Answer»

The correct choice is (a) (x-y)-Z

The best I can explain: In ARITHMETIC, we GROUP two of the same operators from the left, HENCE x-y-z is EQUIVALENT to (x-y)-z and not x-(y—z).

86.

A program that performs lexical analysis is termed as:(a) scanner(b) lexer(c) tokenizer(d) all of the mentionedI got this question in an internship interview.My question is based upon Lexical Analysis in portion Regular Expressions and Languages of Automata Theory

Answer»

The correct CHOICE is (d) all of the mentioned

Easy explanation: A PROGRAM which performs lexical analysis is called lexer, scanner or lexer. Nowadays, lexer is COMBINED with a parser which allows syntactic analysis.

87.

Are the given two patterns equivalent?(a) gray|grey(b) gr(a|e)y(c) yes(d) noI have been asked this question in an online quiz.This key question is from Converting Regular Expressions to Automata topic in chapter Regular Expressions and Languages of Automata Theory

Answer»

The correct choice is (a) gray|grey

To ELABORATE: PARANTHESIS can be used to DEFINE the scope and precedence of OPERATORS. Thus, both the expression represents the same PATTERN.

88.

Regular grammar is(a) context free grammar(b) non context free grammar(c) english grammar(d) none of the mentionedI got this question in an online quiz.My enquiry is from Regular Language & Expression in chapter Regular Expressions and Languages of Automata Theory

Answer» CORRECT CHOICE is (a) CONTEXT FREE grammar

The best I can explain: Regular grammar is subset of context free grammar.
89.

Which of the following is true?(a) Every subset of a regular set is regular(b) Every finite subset of non-regular set is regular(c) The union of two non regular set is not regular(d) Infinite union of finite set is regularThis question was posed to me at a job interview.This key question is from Regular Language & Expression topic in division Regular Expressions and Languages of Automata Theory

Answer»

Right OPTION is (B) Every finite subset of non-regular set is regular

For EXPLANATION: None.

90.

A regular language over an alphabet a is one that can be obtained from(a) union(b) concatenation(c) kleene(d) All of the mentionedThe question was posed to me in an interview for internship.The query is from Regular Language & Expression topic in chapter Regular Expressions and Languages of Automata Theory

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

To explain I would SAY: NONE.
91.

Generate a regular expression for the following problem statement:P(x): String of length 6 or less for å={0,1}*(a) (1+0+e)6(b) (10)6(c) (1+0)(1+0)(1+0)(1+0)(1+0)(1+0)(d) More than one of the mentioned is correctThis question was posed to me at a job interview.Query is from DFA to Regular Expressions topic in division Regular Expressions and Languages of Automata Theory

Answer»

The CORRECT CHOICE is (a) (1+0+e)6

Best explanation: As the input variables are under Kleene Operation, we NEED to include e,thus option c is not correct,thereby option (a) is the right answer.

92.

Which among the following is not an associative operation?(a) Union(b) Concatenation(c) Dot(d) None of the mentionedThis question was addressed to me in an online interview.My doubt stems from Building Regular Expressions topic in chapter Regular Expressions and Languages of Automata Theory

Answer»

Right answer is (d) None of the mentioned

To explain: It does not matter in which order we group the expression with the OPERATORS as they are associative. If one GETS a chance to group the expression, one should group them from left for convenience. For INSTANCE, 012 is grouped as (01)2.

93.

(a + b*c) most correctly represents:(a) (a +b) *c(b) (a)+((b)*.c)(c) (a + (b*)).c(d) a+ ((b*).c)I have been asked this question in an interview for job.I need to ask this question from Building Regular Expressions in chapter Regular Expressions and Languages of Automata Theory

Answer»

The correct choice is (d) a+ ((B*).C)

Easiest explanation: Following the RULES of precedence, KLEENE or star operation would be done FIRST, then concatenation and finally union or plus operation.

94.

A language can be generated from simple primitive language in a simple way if and only if(a) It is recognized by a device of infinite states(b) It takes no auxiliary memory(c) Both are correct(d) Both are wrongThe question was asked in my homework.The doubt is from Regular Expression-Introduction topic in chapter Regular Expressions and Languages of Automata Theory

Answer»

Correct OPTION is (b) It takes no auxiliary memory

Easiest explanation: A LANGUAGE is regular if and only if it can be accepted by a FINITE automaton. Secondly, It supports no concept of auxiliary memory as it loses the data as soon as the device is SHUT down.