CD MCQ
CD MCQ
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)
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
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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 { }.
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.
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.
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".