0% found this document useful (0 votes)
89 views34 pages

CD MCQ

MULTIPLE CHOICE QUESTIONS

Uploaded by

csehod
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
89 views34 pages

CD MCQ

MULTIPLE CHOICE QUESTIONS

Uploaded by

csehod
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 34

COMPILER DESIGN –OBJECTIVE TYPE QUESTIONS

1. 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 2 n

b) 2mn

c) 2(m+n)

d) all of the mentioned


View Answer
Answer: b
Explanation: 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

2. 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
View Answer
Answer: c
Explanation: The Definition of FSM states that M can be transformed to N by relabeling its states or its
edges.

3. Which of the following statement is correct?


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
View Answer
Answer: b
Explanation: Context-free languages are closed under the following operations. The Kleene star, the
concatenation, the union and the intersection.

4. Consider the following two statements.

S1: { 0 2n
|n >= l} is a regu1ar language

S2: {0 0 0
m n (m+n)
l m >= 1 and n >= 2} is a regu1ar language
Which of the following is true?
a) Only S1 is correct
b) Only S2 is correct
c) Both S1 and S2 are correct
d) None of S1 and S2 is correct
View Answer
Answer: c
Explanation: S1 can be written as (00) where n >= 1. And S2 can be written as (00) where m >=2 and n
n (m+n)

>= 1. S2 can be further reduced to (00) where x >= 3. SO we can write regular grammars for both
x

G1 -> G100/00 (For S1)


G2 -> G200/000000 (For S2).

5. Which of the following pairs of regular expressions are equivalent?


a) 1(01)* and (10)*1
b) x (xx)* and (xx)*x
x and x x
c) + + (*+)

d) All of the mentioned


View Answer
Answer: d
Explanation: Rule (pq)*p=p (qp)*
Therefore–(xx*) (x*x**)
(xx*)(x*x*) [Using x**=x] (xx*)(x*) [Using x*x*=x*] (xx*) [Using x*xx*=x*)
x+

6. Which of the following strings is not generated by the following grammar?


S → SaSbS|ε
a) aabb
b) abab
c) aababb
d) aaabbb
View Answer
Answer: d
Explanation: Given S → SaSbS|ε
S->aSbS putting S-> € and then S->SaSbS
S->aSaSaSbSbSbS putting S->SaSbS
S->aaabbb putting S->€.

7. Regular expressions can be used only for values of type string and number.
a) True
b) False
View Answer
Answer: b
Explanation: RE is used for all types of string and numbers.

8. What is the Regular Expression Matching Zero or More Specific Characters?


a) x
b) #
c) *
d) &
View Answer
Answer: c
Explanation: Zero or Specific Expression matching can be done only by a single character that is*.

9. All __________ are automatically treated as regular expressions.


a) Programmatic description
b) Window
c) Win Object
d) Collection
View Answer
Answer: a
Explanation: It is seen that programmatic description are treated as regular expression.

10. Regular Expressions can be used with XML checkpoints.


a) True
b) False
View Answer
Answer: a
Explanation: XML checkpoints employ RE.

11. The production Grammar is {S->aSbb,S->abb} is __________ grammar.


a) Type-3
b) Type-2
c) Type-1
d) Type-0
View Answer
Answer: b
Explanation: As per the definition of type-2 grammar.

12. Regular expression (x/y)(x/y) denotes which of the following set?


a) {xy,xy}
b) {xx,xy,yx,yy}
c) {x,y}
d) {x,y,xy}
View Answer
Answer: b
Explanation: From first part if we take x then from the latter part x then it forms xx
From first part if we take x then from the latter part y then it forms xy
From first part if we take y then from the latter part x then it forms yx
From first part if we take y then from the latter part y then it forms yy.

13. Regular expression x/y denotes which of the following set?


a) {x,y}
b) {xy}
c) {x}
d) {y}
View Answer
Answer: a
Explanation: Because either x or y can be selected.

14. The regular expressions denote zero or more instances of an x or y is?


a) (x+y)
b) (x+y)*
c) (x* + y)
d) (xy)*
View Answer
Answer: b
Explanation: For instances of x or y the exp is x+y and both can zero or more times than (x+y)*.

15. A system program that combines separately compiled modules of a program into a form suitable for
execution is called ___________
a) Assembler
b) Linking loader
c) Cross compiler
d) None of the mentioned
View Answer
Answer: b
Explanation: The definition of cross compiler.

16. A compiler for a high-level language that runs on one machine and produces code for a different
machine is called ___________
a) Optimizing compiler
b) One pass compiler
c) Cross compiler
d) Multipass compiler
View Answer
Answer: c
Explanation: A compiler for a high-level language that runs on one machine and produces code for a
different machine is called cross compiler.

17. Cross-compiler is a compiler __________


a) Which is written in a different language from the source language?
b) That generates object code for the machine it’s running on.
c) Which is written in the same language as the source language?
d) That runs on one machine but produces object code for another machine
View Answer
Answer: a
Explanation: A compiler for a high-level language that runs on one machine and produces code for a
different machine is called a cross compiler.

18. Cross compiler is used in Bootstrapping.


a) True
b) False
View Answer
Answer: a
Explanation: Bootstrapping to a new platform. When software is developed for a new platform, a cross
compiler is used to compile necessary tools such as the OS and a native compiler.

19. Is GCC a cross Complier.


a) Yes
b) No
View Answer
Answer: a
Explanation: GCC, a free software collection of compilers, also can be used as cross compile. It supports
many languages and platforms.

20. The __________ is a technique for building cross compilers for other machines.
a) Brazilian Cross
b) Canadian Cross
c) Mexican Cross
d) X-cross
View Answer
Answer: b
Explanation: The Canadian Cross is a technique for building cross compilers for other machines. Given
three machines X, Y, and Z, one uses machine X (e.g. running Windows XP on an IA-32 processor) to build
a cross compiler that runs on machine Y (e.g. running Mac OS X on an x86-64 processor) to create
executables for machine Z.

21. __________ was developed from the beginning as a cross compiler.


a) Free Pascal
b) GCC
c) Pascal
d) None of the mentioned
View Answer
Answer: a
Explanation: Free Pascal was developed from the beginning as a cross compiler. The compiler executable
(ppcXXX where XXX is target architecture) is capable of producing executables for all OS of the same
architecture.
22. What is the output of lexical analyzer?
a) A set of RE
b) Syntax Tree
c) Set of Tokens
d) String Character
View Answer
Answer: c
Explanation: A lexical analyzer coverts character sequences to set of tokens.

23. Which symbol table implementation is based on the property of locality of reference?
a) Linear list
b) Search tree
c) Hash Table
d) Self Organisation
View Answer
Answer: c
Explanation: Hash table is used as a reference for symbol table because it is efficient.

24. Which of the following is true for operator precedence parsing?


a) For all pair of non-terminal
b) For all pair of non-terminals
c) To delimit the handle
d) None of the mentioned
View Answer
Answer: a
Explanation: 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.

25. What is an Object program?


a) Program written in machine language
b) Program to be translated into machine language
c) Translation of high-level language into machine language
d) None of the mentioned
View Answer
Answer: c
Explanation: Since the input is the source language and the output that we get after the analysis is the
machine language.

26. Which concept of FSA is used in the compiler?


a) Lexical analysis
b) Parser
c) Code generation
d) Code optimization
View Answer
Answer: a
Explanation: Because the lexer performs its analysis by going from one stage to another.

27. Which concept of grammar is used in the compiler?


a) Lexical analysis
b) Parser
c) Code generation
d) Code optimization
View Answer
Answer: b
Explanation: As the lexical analysis of a grammar takes place in phases hence it is synonymous to parser.

28. Which of the following are Lexemes?


a) Identifiers
b) Constants
c) Keywords
d) All of the mentioned
View Answer
Answer: d
Explanation: Different Lexical Classes or Tokens or Lexemes Identifiers, Constants, Keywords, Operators.

29. What constitutes the stages of the compilation process?


a) Feasibility study, system, design, and testing
b) Implementation and documentation
c) Lexical analysis, syntax, Analysis and code generation
d) None of the mentioned
View Answer
Answer: c
Explanation: As defined in the compilation process.

30. The lexical analyzer takes _________ as input and produces a stream of _______ as output.
a) Source program, tokens
b) Token, source program
c) Either of the two
d) None of the mentioned
View Answer
Answer: a
Explanation: As per the definition of Lexical Analyser which states that lexical analysis is the process of
converting a sequence of characters into tokens.
31. Parsing is also known as ________
a) Lexical Analysis
b) Syntax Analysis
c) Semantic Analysis
d) Code Generation
View Answer
Answer: b
Explanation: Parsing or syntactic analysis is the process of analysing a string of symbols and conforming
to the rules of grammar.

32. A compiler program written in a high level language is called ________


a) Source Program
b) Object Program
c) Machine Language Program
d) None of the mentioned
View Answer
Answer: a
Explanation: The input that we give in high level language is also known as the source language.

33. System program such a compiler are designed so that they are ________
a) Re-enterable
b) Non-Usable
c) Serially usable
d) None of the mentioned
View Answer
Answer: a
Explanation: For the convince of the user compilers are made re-enterable.

34. Which of the following is not a feature of compiler?


a) Scan the entire program first and translate into machine code
b) To remove syntax errors
c) Slow for debugging
d) Execution time is more
View Answer
Answer: d
Explanation: The objective of the compiler is clearly not to increase the execution time of the program.

35. 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
View Answer
Answer: b
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.

36. A programmer by mistakes writes a program to multiply two numbers instead of dividing them, how
can this error be detected?
a) Compiler
b) Interpreter
c) Compiler or interpreter
d) None of the mentioned
View Answer
Answer: d
Explanation: This is a logical error that can’t be detected by any compiler or interpreter.

37. A regular expression enables a quick test to determine objects and text strings with undependable
values.
a) True
b) False
View Answer
Answer: a
Explanation: Because it checks for all the values and determines whether the output string matches with
the given string.

38. RE can be used only for values of type string and number.
a) True
b) False
View Answer
Answer: b
Explanation: No not for all values the string and numbers can we use the RE.

39. You can use RE, if you expect the value of a property to change in an unpredictable way each time its
run.
a) True
b) False
View Answer
Answer: b
Explanation: For every cycle the values does not change unpredictably because the type of grammar that
it accepts is defined.

40. All ___________ are automatically treated as regular expressions.


a) Programmatic description
b) Window
c) Win Object
d) Collection
View Answer
Answer: a
Explanation: The programmatic description is genuinely treated as regular expression.

41. If a ‘/’ is used before a character that has no special meaning, ‘/’ is ignored.
a) True
b) False
View Answer
Answer: a
Explanation: The backslash carries no significance and it is ignored.

42. The regular expression denotes a language comprising all possible strings of even length over the
alphabet (0, 1).
a) 1 + 0(1+0)*
b) (0+1) (1+0)*
c) (1+0)
d) (00+0111+10)*
View Answer
Answer: d
Explanation: Option 1 + 0(1+0)* → It does not consider even length criteria for the question.
Option (0+1) (1+0)* → It can so happen here that from the former bracket it takes 0 or 1 and takes null
from the latter then it forms a string of odd length
Option (1+0) → It gives either 1 or 0.
Hence Option (00+0111+10)* is the answer.

43. The RE gives none or many instances of an x or y is?


a) (x+y)
b) (x+y)*
c) (x* + y)
d) (xy)*
View Answer
Answer: b
Explanation: Whether x or y is denoted by x+y and for zero or more instances it is denoted but (x+y)*.

44. The RE in which any number of 0′s is followed by any number of 1′s followed by any number of 2′s is?
a) (0+1+2)*
b) 0*1*2*
c) 0* + 1 + 2
d) (0+1)*2*
View Answer
Answer: b
Explanation: The order for the desired string is 012 and for any number of 0s we write 0* for any number
of 1s we denote it by 1* and similarly for 2*.Thus 0*1*2*.

45. The regular expression have all strings of 0′s and 1′s with no two consecutive 0′s is?
a) (0+1)
b) (0+1)*
c) (0+∈) (1+10)*
d) (0+1)* 011
View Answer
Answer: c
Explanation: From the former bracket we choose 0 or epsilon. Then from the latter part 1 or 10 which can
be followed by 1 or 10.

46. The regular expression with all strings of 0′s and 1′s with at least two consecutive 0′s is?
a) 1 + (10)*
b) (0+1)*00(0+1)*
c) (0+1)*011
d) 0*1*2*
View Answer
Answer: b
Explanation: The expression (0+1)*00(0+1)* is where either it initially takes 0 or 1 or 00 followed by string
of combination of 0 and 1.

47. Which of the following is NOT the set of regular expression R = (ab + abb)* bbab?
a) ababbbbab
b) abbbab
c) ababbabbbab
d) abababab
View Answer
Answer: a
Explanation: ab followed by abb which is followed by bbab.

48. String generated by following expression is?


S->aS/bA, A->d/ccA
a) aabccd
b) adabcca
c) abcca
d) abababd
View Answer
Answer: a
Explanation: S->aS (substitute S->aS)
S->aaS (substitute S->bA)
S->aabA (substitute A->ccA)
S->aabccA (substitute A->d)
S->aabccd.

49. Consider the production of the grammar S->AA A->aa A->bb Describe the language specified by the
production grammar.
a) L = {aaaa,aabb,bbaa,bbbb}
b) L = {abab,abaa,aaab,baaa}
c) L = {aaab,baba,bbaa,bbbb}
d) L = {aaaa,abab,bbaa,aaab}
View Answer
Answer: a
Explanation: S->AA (substitute A->aa)
S->aaaa
S->AA (substitute A->aa )
S->aaA (substitute A->bb)
S->aabb
S->AA (substitute A->bb the A->aa)
S->bbaa
S->AA (substitute A->bb)
S->bbbb.

50. If R is regular language and Q is any language (regular/ non regular), then Pref (Q in R) is _____________
a) Non-regular
b) Equal
c) Infinite
d) Regular
View Answer
Answer: d
Explanation: So says the definition of Regular Grammar.

51. The production of the form no terminal → Λ is said to be null production.


a) False
b) True
View Answer
Answer: b
Explanation: Here the non terminal that gives null will said to have a null production.
52. 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 S
View Answer
Answer: b
Explanation: The definition of the grammar is set of symbols over Σ.

53. What is the transitional function of a DFA?


a) Q X Σ→Q
b) Q X Σ→2Q
c) Q X Σ→2n
d) Q X Σ→Qn
View Answer
Answer: a
Explanation: Q is the finite set and let be a finite set of symbols so Q X Σ fives no of states.

54. What is the transitional function of an NFA?


a) Q X Σ→Q
b) Q X Σ→2Q
c) Q X Σ→2n
d) Q X Σ→Qn
View Answer
Answer: b
Explanation: 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 >.

55. Maximum number of states of a DFA converted from an NFA with nstates is?
a) n
b) n2

c) 2n
d) None of the mentioned
View Answer
Answer: c
Explanation: Take the NFA with states {qo,q1}, alphabet Σ={a}, initial state q0, transitions δ(q0,a)=q0,
δ(q0,a)=q1 and final state q1. It generates the same language as the DFA with the same set of states and
alphabet, but transitions δ(q0,a)=q1 and δ(q1,a)=q1.

56. What are the basic limitations of finite state machine?


a) It cannot remember arbitrarily large amount of information
b) In cannot remember state transitions
c) In cannot remember grammar for a language
d) It cannot remember language generated from a grammar
View Answer
Answer: b
Explanation: Because it does to store its previous state of the transition.

57. 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 inputs
View Answer
Answer: b
Explanation: Palindromes cannot be recognized by FSM.

58. A finite automata recognizes ____________


a) Any Language
b) Context Sensitive Language
c) Context Free Language
d) Regular Language
View Answer
Answer: d
Explanation: All regular languages are implemented by finite automata.

59. 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 deads
View Answer
Answer: c
Explanation: It is a rejecting state for if the control enters it reaches the dead end and cannot reach an
accepting state.

60. 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 input
View Answer
Answer: a
Explanation: The definition states that moore machines output is determined by the current state only.

61. 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 input
View Answer
Answer: c
Explanation: The definition states that its output is determined by current state and current input.

62. 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 deads
View Answer
Answer: a
Explanation: The very meaning of in accessible state is that it cannot be reached at any point of time.

63. In Mealy Machine O/P is associated with ____________


a) Present state
b) Next state
c) Input
d) None of the mentioned
View Answer
Answer: b
Explanation: The definition states that its output is determined by current state and current input.
64. In Moore Machine O/P is associated with ____________
a) Present state
b) Next state
c) Input
d) None of the mentioned
View Answer
Answer: a
Explanation: The definition states that moore machines output is determined by the current state only.

65. Which type of string is accepted by the following finite automata?


a) All string
b) Null string
c) No string
d) None of the mentioned
View Answer
Answer: b
Explanation: Null strings are not accepted by finite automata.

66. Myhill-Nerode Theorem is used for __________


a) Minimization of DFA
b) Maximization of NFA
c) Conversion of NFA
d) Conversion of DFA
View Answer
Answer: a
Explanation: 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.

67. NDFAs where introduced by ____________


a) Michael O Rabin & Dana Scott
b) Dan Brown
c) Sun micro system Labs
d) SAP Labs
View Answer
Answer: a
Explanation: NFAs were introduced Dana Scott and Michael O. Rabin who also showed their equivalence
to DFAs.
68. The regular languages are not closed under ___________
a) Concatenation
b) Union
c) Kleene star
d) Complement
View Answer
Answer: d
Explanation: RE are closed under
Union (cf. picture)
Intersection
Concatenation
Negation
Kleene closure.

69. The Tuples for NDFA is ___________


a) ∑, Q, q0, F, δ
b) Q, q0, F, δ
c) Θ, Q, q0, F,δ
d) F, Q, Δ, q0, δ
View Answer
Answer: a
Explanation: An NFA is represented formally by a 5-tuple, (Q, Σ, Δ, q0, F), of
a set of states Q
a set of input symbols Σ
a transition function Δ : Q × Σ → P(Q).
an initial state q0 ∈ Q
a final state F ⊆ Q.

70. NFAs are ________ DFAs.


a) Larger than
b) More expressive than
c) Less expressive than
d) Equally expressive as
View Answer
Answer: a
Explanation: Because there is more number of states for an NDFA than for a DFA for a given expression.
71. An NFA’s transition function returns ________
a) A Boolean value
b) A state
c) A set of states
d) An edge
View Answer
Answer: c
Explanation: A transition function Δ: Q × Σ → P (Q).Where P (Q) denotes the power set of Q.

72. Conversion of a DFA to an NFA __________


a) Is impossible
b) Requires the subset construction
c) Is Chancy
d) Is nondeterministic
View Answer
Answer: b
Explanation: 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.

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 NFA
View Answer
Answer: b
Explanation: A regular grammar takes in all strings over an alphabet.

74. An NFA may be converted to a DFA using __________


a) Induction
b) A construction
c) Contradiction
d) Compilation
View Answer
Answer: b
Explanation: subset construction is used to convert a NFA into DFA.

75. The subset construction shows that every NFA accepts a __________
a) String
b) Function
c) Regular language
d) Context-free language
View Answer
Answer: c
Explanation: Like DFAs, NFAs only recognize regular languages.

76. Construct a NDFA for the following regular expression.


(a∪b)*aba(a∪b)*

a)

b)

c)
d) None of the mentioned
View Answer
Answer: a
Explanation: The NDFA initially takes either a or b followed by a then b then reaches the final state or
takes iterations of a or b to reach the final state.

77. 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 mentioned
View Answer
Answer: d
Explanation: As per its definition.

78. For every NFA a deterministic finite automaton (DFA) can be found that accepts the same language.
a) True
b) False
View Answer
Answer: a
Explanation: 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.

79. Like DFAs, NFAs only recognize regular languages.


a) True
b) False
View Answer
Answer: a
Explanation: It is a known fact.

80. Can a DFA simulate NDFA?


a) No
b) Yes
c) Sometimes
d) Depends on NDFA
View Answer
Answer: b
Explanation: Yes it can be done through power set construction.
81. 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 mentioned
View Answer
Answer: c
Explanation: The vice versa is true.

82. Regular expression a/b denotes which of the following set?


a) {a}
b) {€,a,b}
c) {a,b}
d) {ab}
View Answer
Answer: c
Explanation: Either a is the output or b hence it’s {a, b}.

83. Which behaviour of a NFA can be stimulated by DFA?


a) Always
b) Sometimes
c) Never
d) Depends on NFA
View Answer
Answer: a
Explanation: It can be done through power set construction.

84. 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) False
View Answer
Answer: a
Explanation: It the standard procedure to convert NFA to DFA.
85. What is the relation between NFA-accepted languages and DFA accepted languages?
a) >
b) <
c) =
d) <=
View Answer
Answer: c
Explanation: The no of languages accepted by NFA and DFA is equal.

86. In regular expressions, the operator ‘*’ stands for?


a) Concatenation
b) Selection
c) Iteration
d) Addition
View Answer
Answer: c
Explanation: It indicates iterations which can vary from zero to any number.

87.t of the language accepted by the NFA shown below? Assume ∑ = {a} and ε is the empty string.

a) Φ
b) ε
c) a
d) {a, ε}
View Answer
Answer: b
Explanation: The given alphabet ∑ contains only one symbol {a} and the given NFA accepts all strings with any
number of occurrences of ‘a’. Hence the complement is an empty string.

88. Given the language L = {ab, aa, baa}, whih of the following strings are in L*?
i) abaabaaabaa
ii) aaaabaaaa
iii) baaaaabaaaab
iv) baaaaabaa

a) i, ii and iii
b) ii, iii and iv
c) i, ii and iv
d) i, iii and iv
View Answer
Answer: c
Explanation: Any combination of strings in set {ab, aa, baa} will be in L*.
i) “abaabaaabaa” can be partitioned as a combination of strings in set {ab, aa, baa}. The partitions are “ab
aa baa ab aa”
ii) “aaaabaaaa” can be partitioned as a combination of strings in set {ab, aa, baa}. The partitions are “aa ab
aa aa”
iii) “baaaaabaaaab” cannot be partitioned as a combination of strings in set {ab, aa, baa}
iv) “baaaaabaa” can be partitioned as a combination of strings in set {ab, aa, baa}. The partitions are “baa
aa ab aa”.

89. NFA-εs are defined because certain properties can be more easily proved on them as compared to
NFA.
a) True
b) False
View Answer
Answer: a
Explanation: NFA-ε can be transformed into a NFA always, the properties are also true for NFAs.

90. E(q) is known ε-closure of q.


a) True
b) False
View Answer
Answer: a
Explanation: 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. ε-transitions does not add any extra capacity of recognizing formal.
a) True
b) False
View Answer
Answer: a
Explanation: ε-transitions provides a convenient transition in the systems whose current states are not
precisely known.

92. 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 mentioned
View Answer
Answer: b
Explanation: generates the set {an bn, n=1,2,3 ….}which is not regular.

93. The transitions which does not take an input symbol are called ___________
a) ε-transitions
b) λ-transitions
c) ε-transitions & λ-transitions
d) none of the mentioned
View Answer
Answer: c
Explanation: The transitions taking an input symbol are called ε-transitions or λ-transitions.

94. A nondeterministic finite automation with ε-moves is an extension of nondeterministic finite


automation.
a) True
b) False
View Answer
Answer: a
Explanation: Both are equivalent.

95. Is an ordinary NFA and a NFA-ε are equivalent.


a) True
b) False
View Answer
Answer: a
Explanation: Yes ordinary NFA and NFA-ε are the same, in that, given either one, one can construct the
other, which recognizes the same language.

96. 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 mentioned
View Answer
Answer: c
Explanation: If we include A and B in a set and if we write A* it means except then A i.e. B same as B*
means except then B i.e. so if we intersect (A*B*) and B then get A because in any regular language. If we
write A-B then A-B=A intersection B’ so if we intersect A and B means A-B So the intersection of (A*B*) and
B = (BA). intersection B means (BA)-B’ and B’=A so (BA) intersection(A)=A.

97. Find the pair of regular expressions that are equivalent.


a) (0+1)* and (0*+1*)*
b) (0+1)* and (0+1*)*
c) (0+10)* and (0*+10)*
d) All of the mentioned
View Answer
Answer: d
Explanation: All generate all strings of 0’s and 1’s thus are these pairs are equivalent.

98. Which of the following strings is NOT in the Kleene star of the language {011, 10, 110}?
a) 01
b) 10
c) 110
d) 10011101
View Answer
Answer: d
Explanation: Every string in the language {011, 10, 110}* has to be formed from zero or more uses of the
strings 011, 10, and 110. A string may be used more than once.
99. Here is a context-free grammar G: S → AB A → 0A1 | 2 B → 1B | 3A which of the following strings are in
L (G)?
a) 021300211
b) 022111300211
c) None of the mentioned
d) 021300211 & 022111300211
View Answer
Answer: d
Explanation: First, notice that A generates strings of the form 021, where n is 0 or more. Also, B gives zero
or more 1’s, which is followed by one 3, and then A gives something. Since S generates something an A
can generate followed by something a B can generate, the strings in L (G) are of the form 0 21 30 21.

100. The parse tree below represents a rightmost derivation according to the grammar S → AB, A → aS|a,
B → bA. Which of the following are right-sentential forms corresponding to this derivation?

a) aAbAba
b) aababa
c) aABba
d) aSba
View Answer
Answer: b
Explanation: S => AB => AbA => Aba => aSba => aABba => aAbAba => aAbaba => aababa.
101. 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 mentioned
View Answer
Answer: c
Explanation: S => a. A string of length 2 has only one derivation, e.g., S => SS => aS => ab.

102. For the following grammar: S → A | B | 2 A → C0 | D B → C1 | E C → D | E | 3 D → E0 | S E → D1 | S


Identify all the unit pairs.
a) D,C
b) A,B
c) B,C
d) A,C
View Answer
Answer: a
Explanation: The cycle of unit-productions S → A → D → S says that any pair involving only S, A, and D is a
unit pair. Similarly, the cycle S → B → E → S tells us that any pair involving S, B, and E is a unit pair.

103. _________ 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 mentioned
View Answer
Answer: d
Explanation: In a two-phase compiler, ensures that there is a source program and an object program.

104. If the NFA N has n states, then the corresponding DFA D has 2n states.
a) True
b) False
View Answer
Answer: a
Explanation: nfa has n then dfa has at max 2^n.
105. An NFA is nothing more than an ε-NFA with no ε transitions.
a) True
b) False
View Answer
Answer: a
Explanation: An NFA is nothing more than an ε-NFA with no ε transitions. Thus • δ (q, ε) for all states q = ∅.
106. For every DFA, there is an ε-NFA that accepts the same language.
a) True
b) False
View Answer
Answer: a
Explanation: For every DFA, there is an ε-NFA that accepts the same language and Vice Versa.

107. DFAs, NFAs, and ε-NFA s are equivalent.


a) True
b) False
View Answer
Answer: a
Explanation: For every NFA there is an ε-NFA that accepts a similar language and vice versa.

108. Consider the languages L1 = and L2 = {a}. Which one of the following represents L1 L2* U L1*?
a) €
b) a*
c) All of the mentioned
d) None of the mentioned
View Answer
Answer: a
Explanation: L1* = * which is { }.

109. Choose the correct statement for the following daigram.


a) For the language accepted by A which is also a minimal DFA
b) A accepts all strings over {0,1} of length at least 2
c) All of the mentioned
d) None of the mentioned
View Answer
Answer: c
Explanation: The DFA can be minimized to two states and the second state is final state .We reach second
state after a 0.

110. Given the language L = {ab, aa, baa}, which of the following strings are in L*?
1) abaabaaabaa
2) aaaabaaaa
3) baaaaabaaaab
4) baaaaabaa
a) 1, 2, 3
b) 2, 3, 4
c) 1, 2, 4
d) 1, 3, 4
View Answer
Answer: c
Explanation: The given alphabet ∑ contains only one symbol {a} and the given NFA accepts all strings with any
number of occurrences of ‘a’.

111. W hat is the complement of the language accepted by the NFA shown below?
a) A,B
b) B
c) C
d) D,C
View Answer
Answer: b
Explanation: The given alphabet contains only one symbol {a} and the given NFA accepts all strings with
any number of occurrences of ‘a’.

112. Which one of the following languages over the alphabet {0,1} is described by the regular expression?
(0+1)*0(0+1)*0(0+1)*
a) String with substring 00
b) String with at most two 0’s
c) String containg at least two 0’s
d) None of the mentioned
View Answer
Answer: c
Explanation: The regular expression has two 0′s surrounded by (0+1)* which means accepted strings
must have at least 2 0′s.

113. Which one of the following is FALSE?


a) Every NFA can be converted to DFA
b) Every subset of a recursively enumerable set is recursive
c) All of the mentioned
d) None of the mentioned
View Answer
Answer: b
Explanation: Every subset of a recursively enumerable set is recursive.

114. 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 analyzer
View Answer
Answer: a
Explanation: Lexical analysis is the process of converting a sequence of characters into a sequence of
tokens.
115. The context free grammar is ambiguous if ______________
a) The grammar contains non-terminals
b) Produces more than one parse tree
c) Production has two non-terminals side by side
d) None of the mentioned
View Answer
Answer: b
Explanation: Since more than one parse tree is generated hence one than option is available .Therefore
it’s ambiguous.

116. What is another name for Lexical Analyser?


a) Linear Phase
b) Linear Analysis
c) Scanning
d) All of the mentioned
View Answer
Answer: d
Explanation: Lexical Analyzer is also called “Linear Phase” or “Linear Analysis” or “Scanning“.

117. An individual token is called ________


a) Lexeme
b) Lex
c) Lexeme & Lex
d) None of the mentioned
View Answer
Answer: a
Explanation: Individual Token is also Called Lexeme.

118. Lexical Analyser’s Output is given to Syntax Analysis.


a) True
b) False
View Answer
Answer: a
Explanation: Lexical Analyzer’s Output is given to Syntax Analysis.

119. Which phase of the compiler is Lexical Analyser?


a) First
b) Second
c) Third
d) None of the mentioned
View Answer
Answer: a
Explanation: Lexical Analyzer is First Phase of Compiler.

120. Input to Lexical Analyser is _________


a) Source Code
b) Object Code
c) Lexeme
d) None of the mentioned
View Answer
Answer: a
Explanation: Lexical analyser’s Input is Source Code.

121. Lexical Analysis Identifies Different Lexical Units in a _______


a) Source Code
b) Object Code
c) Lexeme
d) None of the mentioned
View Answer
Answer: a
Explanation: Lexical Analysis Identifies Different Lexical Units in a source Code.

122. Which one is a type of Lexeme?


a) Identifiers
b) Constants
c) Keywords
d) All of the mentioned
View Answer
Answer: d
Explanation: All of them along with Operators are different types of lexemes.

123. A ________ is a string of characters which form a syntactic unit.


a) Lexeme
b) Lex
c) Lexeme & Lex
d) None of the mentioned
View Answer
Answer: a
Explanation: A lexeme is a string of characters that form a syntactic unit.

124. The process of forming tokens from an input stream of characters is called __________
a) Liberalisation
b) Characterisation
c) Tokenization
d) None of the mentioned
View Answer
Answer: c
Explanation: The process of forming tokens from an input stream of characters is called tokenization.

125. When expression sum=3+2 is tokenized then what is the token category of 3?
a) Identifier
b) Assignment operator
c) Integer Literal
d) Addition Operator
View Answer
Answer: c
Explanation:
Lexeme
Token category
Sum "Identifier"
= "Assignment operator"
3 "Integer literal"
+ "Addition operator"
2 "Integer literal"
; "End of statement".

126. Which one of the following is a top-down parser?


a) Recursive descent parser
b) Operator precedence parser
c) An LR(k) parser
d) An LALR(k) parser
View Answer
Answer: a
Explanation: Clearly LR & LALR are not top down they are bottom up passers. Also not operator
precedence parser. ut yes recursive descent parser is top down parser. Starts from start symbol & derives
the terminal string.
127. Consider the grammar with non-terminals.
N = {S , C , S}, terminals T = {a, b , i , t, e}, with S as the start symbol,
and the following of rules
S -> iCtSS1 | a
S1 -> eS | ε
C -> b
The grammar is NOTLL(1) because ________
a) It is left recursive
b) It is right recursive
c) It is ambiguous
d) It is not context-free
View Answer
Answer: a
Explanation: The grammar has production S ” iCtSS1 here the right hand side of grammar has the same
symbol as left side. So the grammar is left recursive. The grammar is not ambiguous.

128. Which grammar defines Lexical Syntax?


a) Regular Grammar
b) Syntactic Grammar
c) Context free Grammar
d) Lexical Grammar
View Answer
Answer: d
Explanation: The specification of a programming language often includes a set of rules, the lexical
grammar, which defines the lexical syntax.

You might also like