Automata
Automata
View Answer
Answer: b
Explanation: δ(QX∑) = Q1 is the correct representation of change of state.
Here, δ is called the Transition function.
10. Given: ∑= {a, b}
L= {xϵ∑*|x is a string combination}
∑4 represents which among the following?
a) {aa, ab, ba, bb}
b) {aaaa, abab, ε, abaa, aabb}
c) {aaa, aab, aba, bbb}
d) All of the mentioned
View Answer
Answer: b
Explanation: ∑* represents any combination of the given set while ∑x
represents the set of combinations with length x where x ϵ I.
1. Moore Machine is an application of:
a) Finite automata without input
b) Finite automata with output
c) Non Finite automata with output
d) None of the mentioned
View Answer
Answer: b
Explanation: Finite automaton with output is categorized din two parts:
Moore M/C and Mealy M/C.
2. In Moore machine, output is produced over the change of:
a) transitions
b) states
c) all of the mentioned
d) none of the mentioned
View Answer
Answer: b
Explanation: Moore machine produces an output over the change of
transition states while mealy machine does it so for transitions itself.
3. For a give Moore Machine, Given Input=’101010’, thus the output would
be of length:
a) |Input|+1
b) |Input|
c) |Input-1|
d) Cannot be predicted
View Answer
Answer: a
Explanation: Initial state, from which the operations begin is also initialized
with a value.
Note: Join free Sanfoundry classes at Telegram or Youtube
advertisement
Present State
Next State
Output
0
Q0
Q1
Q2
Q1
Q2
Q2
Q0
a) Q0, Q2, 0
b) Q0, Q2, 1
c) Q1, Q2, 1
d) Q1, Q0, 0
View Answer
Answer: a
Explanation: The table can be filled accordingly seeing the graph.
7. What is the output for the given language?
Language: A set of strings over ∑= {a, b} is taken as input and it prints 1 as
an output “for every occurrence of a, b as its substring. (INPUT: abaaab)
a) 0010001
b) 0101010
c) 0111010
d) 0010000
View Answer
Answer: a
Explanation: The outputs are as per the input, produced.
8. The output alphabet can be represented as:
a) δ
b) ∆
c) ∑
d) None of the mentioned
View Answer
Answer: b
Explanation: Source-The tuple definition of Moore and mealy machine
comprises one new member i.e. output alphabet as these are finite
machines with output.
9. The O/P of Moore machine can be represented in the following format:
a) Op(t)=δ(Op(t))
b) Op(t)=δ(Op(t)i(t))
c) Op(t): ∑
d) None of the mentioned
View Answer
Answer: a
Explanation: Op(t)=δ(Op(t)) is the defined definition of how the output is
received on giving a specific input to Moore machine.
10. Which of the following is a correct statement?
a) Moore machine has no accepting states
b) Mealy machine has accepting states
c) We can convert Mealy to Moore but not vice versa
d) All of the mentioned
View Answer
Answer: a
Explanation: Statement a and b is correct while c is false. Finite machines
with output have no accepting states and can be converted within each
other.
a) 9’s Complement
b) 2’s Complement
c) 1’s Complement
d) 10’s Complement
View Answer
Answer: b
Explanation: The input can be taken in form of a binary string and can be
verified.
Sanfoundry Certification Contest of the Month is Live. 100+ Subjects.
Participate Now!
advertisement
a) 9’s Complement
b) 2’s Complement
c) 1’s Complement
d) 10’s Complement
View Answer
Answer: c
Explanation: Inputs can be taken and can be verified.
10. Which one of the following is true?
A mealy machine
a) produces a language
b) produces a grammar
c) can be converted to NFA
d) has less circuit delays
View Answer
Answer: d
Explanation: It does not produce a language or grammar or can be
converted to a NFA.
1. Which of the following does not belong to input alphabet if S={a, b}* for
any language?
a) a
b) b
c) e
d) none of the mentioned
View Answer
Answer: c
Explanation: The automaton may be allowed to change its state without
reading the input symbol using epsilon but this does not mean that epsilon
has become an input symbol. On the contrary, one assumes that the
symbol epsilon does not belong to any alphabet.
2. The number of final states we need as per the given language?
Language L: {an| n is even or divisible by 3}
a) 1
b) 2
c) 3
d) 4
View Answer
Answer: b
Explanation:
a) 5
b) 7
c) 9
d) 6
View Answer
Answer: b
Explanation:
a) ababaabaa
b) abbbaa
c) abbbaabb
d) abbaabbaa
View Answer
Answer: a
Explanation: All the Strings are getting accepted except ‘ababaabaa’ as it is
directed to dumping state. Dumping state also refers to the reject state of
the automata.
8. Which of the following will the given DFA won’t accept?
a) ε
b) 11010
c) 10001010
d) String of letter count 11
View Answer
Answer: a
Explanation: As the initial state is not made an acceptance state, thus ε will
not be accepted by the given DFA. For the automata to accept ε as an
entity, one should make the initial state as also the final state.
9. Can a DFA recognize a palindrome number?
a) Yes
b) No
c) Yes, with input alphabet as ∑*
d) Can’t be determined
View Answer
Answer: b
Explanation: Language to accept a palindrome number or string will be
non-regular and thus, its DFA cannot be obtained. Though, PDA is
possible.
10. Which of the following is not an example of finite state machine
system?
a) Control Mechanism of an elevator
b) Combinational Locks
c) Traffic Lights
d) Digital Watches
View Answer
Answer: d
Explanation: Proper and sequential combination of events leads the
machines to work in hand which includes The elevator, Combinational
Locks, Traffic Lights, vending machine, etc. Other applications of Finite
machine state system are Communication Protocol Design, Artificial
Intelligence Research, A Turnstile, etc.
1. The password to the admins account=”administrator”. The total number
of states required to make a password-pass system using DFA would be
__________
a) 14 states
b) 13 states
c) 12 states
d) A password pass system cannot be created using DFA
View Answer
Answer: a
Explanation: For a string of n characters with no repetitive substrings, the
number of states required to pass the string is n+1.
2. Which of the following is the corresponding Language to the given DFA?
4. Let the given DFA consist of x states. Find x-y such that y is the number
of states on minimization of DFA?
a) 3
b) 2
c) 1
d) 4
View Answer
Answer: b
Explanation: Use the equivalence theorem or Myphill Nerode theorem to
minimize the DFA.
5. For a machine to surpass all the letters of alphabet excluding vowels,
how many number of states in DFA would be required?
a) 3
b) 2
c) 22
d) 27
View Answer
Answer: a
Explanation:
b)
c)
d)
View Answer
Answer: a
Explanation: The states transited has been written corresponding to the
transitions as per the row and column. The row represents the transitions
made and the ultimate.
2.Let u=’1101’, v=’0001’, then uv=11010001 and vu= 00011101.Using the
given information what is the identity element for the string?
a) u-1
b) v-1
c) u-1v-1
d) ε
View Answer
Answer: d
Explanation: Identity relation: εw = wε = w, thus the one satisfying the given
relation will be the identity element.
Check this: Computer Science MCQs | Automata Theory Books
3.Which of the following substring will the following notation result?
a) 0101011
b) 0101010
c) 010100
d) 100001
View Answer
Answer: c
Explanation: The given DFA notation accepts the string of even length and
prefix ‘01’.
4.Predict the following step in the given bunch of steps which accepts a
strings which is of even length and has a prefix=’01’
δ (q0, ε) =q0 < δ(q0,0) =δ (δ (q0, ε),0) = δ(q0,0) =q1 < _______________
a) δ (q0, 011) =δ (δ (q0,1), 1) =δ (q2, 1) =q3
b) δ (q0, 01) =δ (δ (q0, 0), 1) = δ (q1, 1) =q2
c) δ (q0, 011) =δ (δ (q01, 1), 1) =δ (q2, 0) =q3
d) δ (q0, 0111) =δ (δ (q0, 011), 0) = δ (q3, 1) =q2
View Answer
Answer: b
Explanation: Here, δ refers to transition function and results into new state
or function when an transition is performed over its state.
5. Fill the missing blank in the given Transition Table:
Language L= {xϵ∑= {0,1} |x accepts all the binary strings not divisible by 3}
a) Q0
b) Q1
c) Q2
d) No Transition
View Answer
Answer: b
Explanation: The tabular representation of DFA is quite readable and can
be used to some ore complex problems. Here, we need to form the
transition graph and fill up the given blank.
6. Which among the following is the missing transition in the given DFA?
L= {xϵ∑= {a, b} | x starts with a and ends with b}
a) δ (q0, a) = q0
b) δ (F, a) = q1
c) δ (F, a) = D
d) δ (q1, a) = D
View Answer
Answer: b
Explanation: For the given Language, the transition missing is δ (F, a) = q1.
7. The complement of a language will only be defined when and only when
the __________ over the language is defined.
a) String
b) Word
c) Alphabet
d) Grammar
View Answer
Answer: c
Explanation: It is not possible to define the complement of a language
without defining the input alphabets. Example: A language which does not
consist of substring ‘ab’ while the complement would be the language
which does contain a substring ‘ab’.
8. Which among the following is not notated as infinite language?
a) Palindrome
b) Reverse
c) Factorial
d) L={ab}*
View Answer
Answer: c
Explanation: Factorial, here is the most appropriate non-infinite domain.
Otherwise, palindrome and reverse have infinite domains.
9. Which among the following states would be notated as the final
state/acceptance state?
L= {xϵ∑= {a, b} | length of x is 2}
a) q1
b) q2
c) q1, q2
d) q3
View Answer
Answer: b
Explanation: According to the given language, q2 Is to become the
final/acceptance state in order to satisfy.
10. Which of the following are the final states in the given DFA according to
the Language given.?
L= {xϵ∑= {a, b} |length of x is at most 2}
a) q0, q1
b) q0, q2
c) q1, q2
d) q0, q1, q2
View Answer
Answer: d
Explanation: According to the given language, the length is at most 2, thus
the answer is found accordingly.
1. How many languages are over the alphabet R?
a) countably infinite
b) countably finite
c) uncountable finite
d) uncountable infinite
View Answer
Answer: d
Explanation: A language over an alphabet R is a set of strings over A which
is uncountable and infinite.
2. According to the 5-tuple representation i.e. FA= {Q, ∑, δ, q, F}
Statement 1: q ϵ Q’; Statement 2: FϵQ
a) Statement 1 is true, Statement 2 is false
b) Statement 1 is false, Statement 2 is true
c) Statement 1 is false, Statement 2 may be true
d) Statement 1 may be true, Statement 2 is false
View Answer
Answer: b
Explanation: Q is the Finite set of states, whose elements i.e. the states
constitute the finite automata.
3. δˆ tells us the best:
a) how the DFA S behaves on a word u
b) the state is the dumping state
c) the final state has been reached
d) Kleene operation is performed on the set
View Answer
Answer: a
Explanation: δ or the Transition function describes the best, how a DFA
behaves on a string where to transit next, which direction to take.
Sanfoundry Certification Contest of the Month is Live. 100+ Subjects.
Participate Now!
advertisement
a) divisible by 3
b) divisible by 2
c) divisible by 2 and 3
d) divisible by 3 and 2
View Answer
Answer: d
Explanation: The given DFA accepts all the binary strings such that they
are divisible by 3 and 2.Thus, it can be said that it also accepts all the
strings which is divisible by 6.
7. Given:
L1= {xϵ ∑*|x contains even no’s of 0’s}
L2= {xϵ ∑*|x contains odd no’s of 1’s}
No of final states in Language L1 U L2?
a) 1
b) 2
c) 3
d) 4
View Answer
Answer: c
Explanation:
a) Correct
b) Incorrect, Incomplete DFA
c) Wrong proposition
d) May be correct
View Answer
Answer: c
Explanation: The given figure is an NFA. The statement contradicts itself.
3. What is wrong in the given definition?
Def: ({q0, q1, q2}, {0,1}, δ, q3, {q3})
a) The definition does not satisfy 5 Tuple definition of NFA
b) There are no transition definition
c) Initial and Final states do not belong to the Graph
d) Initial and final states can’t be same
View Answer
Answer: c
Explanation: q3 does not belong to Q where Q= set of finite states.
Note: Join free Sanfoundry classes at Telegram or Youtube
advertisement
4. If δ is the transition function for a given NFA, then we define the δ’ for the
DFA accepting the same language would be:
Note: S is a subset of Q and a is a symbol.
a) δ’ (S, a) =Upϵs δ (p, a)
b) δ’ (S, a) =Up≠s δ (p, a)
c) δ’ (S, a) =Upϵs δ(p)
d) δ’ (S) =Up≠s δ(p)
View Answer
Answer: a
Explanation: According to subset construction, equation 1 holds true.
5. What is the relation between DFA and NFA on the basis of
computational power?
a) DFA > NFA
b) NFA > DFA
c) Equal
d) Can’t be said
View Answer
Answer: c
Explanation: DFA is said to be a specific case of NFA and for every NFA
that exists for a given language, an equivalent DFA also exists.
Check this: Automata Theory Books | Computer Science Books
6. If a string S is accepted by a finite state automaton,
S=s1s2s3……sn where siϵ∑ and there exists a sequence of states r0, r1,
r2…… rn such that δ(r(i), si+1) =ri+1 for each 0, 1, …n-1, then r(n) is:
a) initial state
b) transition symbol
c) accepting state
d) intermediate state
View Answer
Answer: c
Explanation: r(n) is the final state and accepts the string S after the string
being traversed through r(i) other states where I ϵ 01,2…(n-2).
7. According to the given table, compute the number of transitions with 1 as
its symbol but not 0:
a) 4
b) 3
c) 2
d) 1
View Answer
Answer: d
Explanation: The transition graph is made and thus the answer can be
found.
8. From the given table, δ*(q0, 011) =?
a) {q0}
b) {q1} U {q0, q1, q2}
c) {q2, q1}
d) {q3, q1, q2, q0}
View Answer
Answer: b
Explanation: δ*(q0,011) = Urϵδ*(q0,01) δ (r, 1) = {q0, q1, q2}.
9. Number of times the state q3 or q2 is being a part of extended 6
transition state is
a) 6
b) 5
c) 4
d) 7
View Answer
Answer: a
Explanation: According to the question, presence of q2 or q1 would count
so it does and the answer according to the diagram is 6.
10. Predict the missing procedure:
i.Δ(Q0, ε) ={Q0},
ii.Δ(Q0, 01) = {Q0, Q1}
iii.δ(Q0, 010) =?
a) {Q0, Q1, Q2}
b) {Q0, Q1}
c) {Q0, Q2}
d) {Q1, Q2}
View Answer
Answer: c
Explanation: According to given table and extended transition state
implementation, we can find the state at which it rests.
1. Subset Construction method refers to:
a) Conversion of NFA to DFA
b) DFA minimization
c) Eliminating Null references
d) ε-NFA to NFA
View Answer
Answer: a
Explanation: The conversion of a non-deterministic automata into a
deterministic one is a process we call subset construction or power set
construction.
2. Given Language:
Ln= {xϵ {0,1} * | |x|≥n, nth symbol from the right in x is 1}
How many state are required to execute L3 using NFA?
a) 16
b) 15
c) 8
d) 7
View Answer
Answer: b
Explanation: The finite automaton for the given language is made and thus,
the answer can be obtained.
3. Which of the following does the given NFA represent?
a) 2
b) 3
c) 1
d) 0
View Answer
Answer: a
Explanation:
4. John is asked to make an automaton which accepts a given string for all
the occurrence of ‘1001’ in it. How many number of transitions would John
use such that, the string processing application works?
a) 9
b) 11
c) 12
d) 15
View Answer
Answer: a
Explanation:
10. The total number of states to build the given language using DFA:
L = {w | w has exactly 2 a’s and at least 2 b’s}
a) 10
b) 11
c) 12
d) 13
View Answer
Answer: a
Explanation: We need to make the number of a as fixed i.e. 2 and b can be
2 or more. Thus, using this condition a finite automata can be created using
1 states.
1. Given Language: {x | it is divisible by 3}
The total number of final states to be assumed in order to pass the number
constituting {0, 1} is
a) 0
b) 1
c) 2
d) 3
View Answer
Answer: c
Explanation: The DFA for the given language can be constructed as
follows:
a)
b)
c)
d) None of the mentioned
View Answer
Answer: a
Explanation: The NFA accepts all binary strings such that the third bit from
right end is 1 and if not, is send to Dumping state. Note: It is assumed that
the input is given from the right end bit by bit.
7. Statement 1: NFA computes the string along parallel paths.
Statement 2: An input can be accepted at more than one place in an NFA.
Which among the following options are most appropriate?
a) Statement 1 is true while 2 is not
b) Statement 1 is false while is not
c) Statement 1 and 2, both are true
d) Statement 1 and 2, both are false
View Answer
Answer: c
Explanation: While the machine runs on some input string, if it has the
choice to split, it goes in all possible way and each one is different copy of
the machine. The machine takes subsequent choice to split further giving
rise to more copies of the machine getting each copy run parallel. If any
one copy of the machine accepts the strings, then NFA accepts, otherwise
it rejects.
8. Which of the following options is correct for the given statement?
Statement: If K is the number of states in NFA, the DFA simulating the
same language would have states less than 2k.
a) True
b) False
View Answer
Answer: a
Explanation: If K is the number of states in NFA, the DFA simulating the
same language would have states equal to or less than 2k.
9. Let N (Q, ∑, δ, q0, A) be the NFA recognizing a language L. Then for a
DFA (Q’, ∑, δ’, q0’, A’), which among the following is true?
a) Q’ = P(Q)
b) Δ’ = δ’ (R, a) = {q ϵ Q | q ϵ δ (r, a), for some r ϵ R}
c) Q’ = {q0}
d) All of the mentioned
View Answer
Answer: d
Explanation: All the optioned mentioned are the instruction formats of how
to convert a NFA to a DFA.
10. There exists an initial state, 17 transition states, 7 final states and one
dumping state, Predict the maximum number of states in its equivalent
DFA?
a) 226
b) 224
c) 225
d) 223
View Answer
Answer: a
Explanation: The maximum number of states an equivalent DFA can
comprise for its respective NFA with k states will be 2 k.
1. Under which of the following operation, NFA is not closed?
a) Negation
b) Kleene
c) Concatenation
d) None of the mentioned
View Answer
Answer: d
Explanation: NFA is said to be closed under the following operations:
a) Union
b) Intersection
c) Concatenation
d) Kleene
e) Negation.
2. It is less complex to prove the closure properties over regular languages
using:
a) NFA
b) DFA
c) PDA
d) Can’t be said
View Answer
Answer: a
Explanation: None.
3. Which of the following is an application of Finite Automaton?
a) Compiler Design
b) Grammar Parsers
c) Text Search
d) All of the mentioned
View Answer
Answer: d
Explanation: There are many applications of finite automata, mainly in the
field of Compiler Design and Parsers and Search Engines.
Sanfoundry Certification Contest of the Month is Live. 100+ Subjects.
Participate Now!
advertisement
4. John is asked to make an automaton which accepts a given string for all
the occurrence of ‘1001’ in it. How many number of transitions would John
use such that, the string processing application works?
a) 9
b) 11
c) 12
d) 15
View Answer
Answer: a
Explanation: None.
5. Which of the following do we use to form an NFA from a regular
expression?
a) Subset Construction Method
b) Power Set Construction Method
c) Thompson Construction Method
d) Scott Construction Method
View Answer
Answer: c
Explanation: Thompson Construction method is used to turn a regular
expression in an NFA by fragmenting the given regular expression through
the operations performed on the input alphabets.
Check this: Computer Science MCQs | Computer Science Books
6. Which among the following can be an example of application of finite
state machine(FSM)?
a) Communication Link
b) Adder
c) Stack
d) None of the mentioned
View Answer
Answer: a
Explanation: Idle is the state when data in form of packets is send and
returns if NAK is received else waits for the NAK to be received.
7. Which among the following is not an application of FSM?
a) Lexical Analyser
b) BOT
c) State charts
d) None of the mentioned
View Answer
Answer: d
Explanation: Finite state automation is used in Lexical Analyser, Computer
BOT (used in games), State charts, etc.
8. L1= {w | w does not contain the string tr }
L2= {w | w does contain the string tr}
Given ∑= {t, r}, The difference of the minimum number of states required to
form L1 and L2?
a) 0
b) 1
c) 2
d) Cannot be said
View Answer
Answer: a
Explanation: None.
9. Predict the number of transitions required to automate the following
language using only 3 states:
L= {w | w ends with 00}
a) 3
b) 2
c) 4
d) Cannot be said
View Answer
Answer: a
Explanation: None.
10. The total number of states to build the given language using DFA:
L= {w | w has exactly 2 a’s and at least 2 b’s}
a) 10
b) 11
c) 12
d) 13
View Answer
Answer: a
Explanation: We need to make the number of a as fixed i.e. 2 and b can be
2 or more. Thus, using this condition a finite automata can be created using
1 states.
1. According to the given transitions, which among the following are the
epsilon closures of q1 for the given NFA?
Δ (q1, ε) = {q2, q3, q4}
Δ (q4, 1) = q1
Δ (q1, ε) = q1
a) q4
b) q2
c) q1
d) q1, q2, q3, q4
View Answer
Answer: d
Explanation: The set of states which can be reached from q using ε-
transitions, is called the ε-closure over state q.
2. State true or false?
Statement: An NFA can be modified to allow transition without input
alphabets, along with one or more transitions on input symbols.
a) True
b) False
View Answer
Answer: a
Explanation: It is possible to construct an NFA with ε-transitions, presence
of no input symbols, and that is called NFA with ε-moves.
3. State true or false?
Statement: ε (Input) does not appears on Input tape.
a) True
b) False
View Answer
Answer: a
Explanation: ε does not appears on Input tape, ε transition means a
transition without scanning a symbol i.e. without moving the read head.
Subscribe Now: Automata Theory Newsletter | Important Subjects
Newsletters
advertisement
a) An Irregular Set
b) R*
c) R complement
d) R reverse
View Answer
Answer: b
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.
7. The given NFA corresponds to which of the following Regular
expressions?
a) (0+1)*001(0+1)*
b) 1*001(0+1)*
c) (01)*(0+0+1)(01)*
d) None of the mentioned
View Answer
Answer: a
Explanation: There needs to be 001 together in the string as an essential
substring. Thus, the other components can be anything, 0 or 1 or e.
2. 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
definition
View Answer
Answer: b
Explanation: Using NFA with e moves, we can represent all the regular
expressions as an automata. As regular expressions include e, we need to
use e moves.
3. The total number of states required to automate the given regular
expression
(00)*(11)*
a) 3
b) 4
c) 5
d) 6
View Answer
Answer: c
Explanation:
Note: Join free Sanfoundry classes at Telegram or Youtube
advertisement
4. Which of the given regular expressions correspond to the automata
shown?
a) (110+1)*0
b) (11+110)*1
c) (110+11)*0
d) (1+110)*1
View Answer
Answer: c
Explanation: There is no state change for union operation, but has two
different paths while for concatenation or dot operation, we have a state
change for every element of the string.
5. Generate a regular expression for the following problem statement:
Password Validation: String should be 8-15 characters long. String must
contain a number, an Uppercase letter and a Lower case letter.
a) ^(?=.*[a-z])(?=.*[A-Z])(?=.*\d).{8,15}$
b) ^(?=.*[a-z])(?=.*[A-Z])(?=.*\d).{9,16}$
c) ^(?=.[a-z])(?=.[A-Z])(?=.\d).{8,15}$
d) None of the mentioned
View Answer
Answer: a
Explanation: Passwords like abc123, 123XYZ, should not be accepted . If
one also wants to include special characters as one of the constraint, one
can use the following regular expression:
^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[^\da-za-Z]).{8,15}$
Check this: Computer Science MCQs | Automata Theory Books
6. 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 correct
View Answer
Answer: a
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.
7. The minimum number of states required in a DFA (along with a dumping
state) to check whether the 3rd bit is 1 or not for |n|>=3
a) 3
b) 4
c) 5
d) 1
View Answer
Answer: c
Explanation:
Explanation:
1. 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 mentioned
View Answer
Answer: c
Explanation: We use this algorithm to simplify a finite automaton to regular
expression or vice versa. We eliminate states while converting given finite
automata to its corresponding regular expression.
2. If we have more than one accepting states or an accepting state with an
outdegree, which of the following actions will be taken?
a) addition of new state
b) removal of a state
c) make the newly added state as final
d) more than one option is correct
View Answer
Answer: d
Explanation: If there is more than one accepting state or if the single
accepting state as an out degree, add a new accepting state, make all
other states non accepting, and hold an e-transitions from each former
accepting state to the new accepting state.
3. Which of the following is not a step in elimination of states procedure?
a) Unifying all the final states into one using e-transitions
b) Unify single transitions to multi transitions that contains union of input
c) Remove states until there is only starting and accepting states
d) Get the resulting regular expression by direct calculation
View Answer
Answer: b
Explanation: While eliminating the states, we unify multiple transitions to
one transition that contains union of input and not the vice versa.
Sanfoundry Certification Contest of the Month is Live. 100+ Subjects.
Participate Now!
advertisement
a) Yes
b) No
View Answer
Answer: a
Explanation: The state q2 can be eliminated with ease and the reduced
state diagram can be represented as:
4. Regular grammar is
a) context free grammar
b) non context free grammar
c) english grammar
d) none of the mentioned
View Answer
Answer: a
Explanation: Regular grammar is subset of context free grammar.
5. 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
b) L1>=L2
c) L1 U L2 = .*
d) L1=L2
View Answer
Answer: d
Explanation: Finite state machine and regular expression have same power
to express a language.
Check this: Computer Science Books | Automata Theory Books
6. Which of the following is not a regular expression?
a) [(a+b)*-(aa+bb)]*
b) [(0+1)-(0b+a1)*(a+b)]*
c) (01+11+10)*
d) (1+2+0)*(1+2)*
View Answer
Answer: b
Explanation: Except b all are regular expression*.
7. Regular expression are
a) Type 0 language
b) Type 1 language
c) Type 2 language
d) Type 3 language
View Answer
Answer: d
Explanation: According to Chomsky hierarchy,
Type 0 – Unrestricted Grammar.
Type 1 – Context Sensitive Grammar.
Type 2 – Context Free Grammar.
Type 3 – Regular Grammar.
8. 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 regular
View Answer
Answer: b
Explanation: None.
9. L and ~L are recursive enumerable then L is
a) Regular
b) Context free
c) Context sensitive
d) Recursive
View Answer
Answer: d
Explanation:If L is recursive enumerable and its complement too if and only
if L is recursive.
10. Regular expressions are closed under
a) Union
b) Intersection
c) Kleen star
d) All of the mentioned
View Answer
Answer: d
Explanation: According to definition of regular expression.
Sanfoundry Global Education & Learning Series – Automata
1. What kind of expressions do we used for pattern matching?
a) Regular Expression
b) Rational Expression
c) Regular & Rational Expression
d) None of the mentioned
View Answer
Answer: c
Explanation: 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.
2. Which of the following do Regexps do not find their use in?
a) search engines
b) word processors
c) sed
d) none of the mentioned
View Answer
Answer: d
Explanation: Regexp processors are found in several search engines,
seach and replace mechanisms, and text processing utilities.
3. Which of the following languages have built in regexps support?
a) Perl
b) Java
c) Python
d) C++
View Answer
Answer: a
Explanation: 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.
Note: Join free Sanfoundry classes at Telegram or Youtube
advertisement
$string1 = "Hello\nWorld\n";
if ($string1 =~ m/d\n\z/) {
print "$string1 is a string ";
print "that ends with 'd\\n'.\n";
}
4. For the given syntax of sed, which among the following is not a correct
option?
General syntax of sed: /pattern/action
a) / are used as delimiters
b) pattern refers to a regular expression
c) pattern refers to the string to be matched
d) action refers to the command
View Answer
Answer: c
Explanation: In the general syntax of sed, pattern is the regular expression
and action refers to the command given (p: prints the line, d: deletes the
line, etc).
5. What does grep do in UNIX?
a) It is an editor in UNIX
b) It searches for text patterns
c) It is an editor in UNIX and it searches for text patterns
d) None of the mentioned
View Answer
Answer: b
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.
Check this: Computer Science Books | Computer Science MCQs
6. State true or false:
Statement: A regular expression is a sequence of characters that represent
a pattern.
a) true
b) false
View Answer
Answer: a
Explanation: Such a generated pattern could be a fixed word or describe
something like more general.
7. Which of the following options support the given statement?
Statement: A regular expression could be a fixed word or describe
something like more general.
a) This flexibility makes Regular expression invaluable
b) This flexibility makes the Regular expression unvaluable
c) This flexibility makes Regular expression invaluable and unvaluable
d) None of the mentioned
View Answer
Answer: a
Explanation: Regular expressions are very much invaluable tools; they can
be used to find a particular segment of line in a file and instruct to take
certain actions.
8. What does the following segment of code does?
grep -i man heroes.txt
a) manually opens a file called heroes.txt
b) manages heroes.txt
c) search for “man” in the file “heroes.txt”
d) none of the mentioned
View Answer
Answer: c
Explanation: grep is a command which finds the pattern in a particular text
segment.Here, it scans each line in heroes.txt and looks for an m followed
by a and then followed by n.
9. What does “X?” do regular expression operator?
a) Matches zero or more capital X’s
b) Matches no or one occurence of the capital letter X
c) Matches one or more capital X’s
d) All of the mentioned
View Answer
Answer: b
Explanation: There are many other common regular expression operators
like $, ^, etc. Which have their own respective purposes.
10. Which of the following does not support regular expressions?
a) sed
b) awk
c) emacs
d) none of the mentioned
View Answer
Answer: d
Explanation: There are many UNIX tools including vi, Emacs, sed, awk and
modern programming languages which support regular expressions.
1. 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 mentioned
View Answer
Answer: b
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.
2. If the lexical analyser finds a lexeme with the same name as that of a
reserved word,it _________
a) overwrites the word
b) overwrites the functionality
c) generates an error
d) something else
View Answer
Answer: c
Explanation: Reserved words are known as keywords and they are specific
and reserved with its functionality to a language. Thus, getting an input with
the same name by the analyzer will generate an error.
3. The methodology to show an error when the analyzer faces a keyword
over an user’s input is based on:
a) rule priority
b) longest match rule
c) keyword-out rule
d) none of mentioned
View Answer
Answer: a
Explanation: The lexical analyzer follows the rule priority where its
prioritizes keywords over an input it gets with the same name as that of the
keyword and thus generates an error.
Sanfoundry Certification Contest of the Month is Live. 100+ Subjects.
Participate Now!
advertisement
4. Let w= xyz and y refers to the middle portion and |y|>0.What do we call
the process of repeating y 0 or more times before checking that they still
belong to the language L or not?
a) Generating
b) Pumping
c) Producing
d) None of the mentioned
View Answer
Answer: b
Explanation: The process of repeatation is called pumping and so, pumping
is the process we perform before we check whether the pumped string
belongs to L or not.
5. There exists a language L. We define a string w such that w∈L and
w=xyz and |w| >=n for some constant integer n.What can be the maximum
length of the substring xy i.e. |xy|<=?
a) n
b) |y|
c) |x|
d) none of the mentioned
View Answer
Answer: a
Explanation: It is the first conditional statement of the lemma that states
that |xy|<=n, i.e. the maximum length of the substring xy in w can be n only.
Check this: Automata Theory Books | Computer Science Books
6. Fill in the blank in terms of p, where p is the maximum string length in L.
Statement: Finite languages trivially satisfy the pumping lemma by having n
= ______
a) p*1
b) p+1
c) p-1
d) None of the mentioned
View Answer
Answer: b
Explanation: Finite languages trivially satisfy the pumping lemma by having
n equal to the maximum string length in l plus 1.
7. Answer in accordance to the third and last statement in pumping lemma:
For all _______ xyiz ∈L
a) i>0
b) i<0
c) i<=0
d) i>=0
View Answer
Answer: d
Explanation: Suppose L is a regular language . Then there is an integer n
so that for any x∈L and |x|>=n, there are strings u,v,w so that
x= uvw
|uv|<=n
|v|>0
for any m>=0, uvmw ∈L.
8. If d is a final state, which of the following is correct according to the given
diagram?
4. If w belongs to L(G), for some CFG, then w has a parse tree, which
defines the syntactic structure of w. w could be:
a) program
b) SQL-query
c) XML document
d) All of the mentioned
View Answer
Answer: d
Explanation: Parse trees are an alternative representation to derivations
and recursive inferences. There can be several parse trees for the same
string.
5. Is the following statement correct?
Statement: Recursive inference and derivation are equivalent.
a) Yes
b) No
View Answer
Answer: a
Explanation: Yes, they are equivalent. Both the terminologies represent the
two approaches of recursive inferencing.
Check this: Computer Science MCQs | Automata Theory Books
6. A->aA| a| b
The number of steps to form aab:
a) 2
b) 3
c) 4
d) 5
View Answer
Answer: b
Explanation: A->aA=>aaA=>aab
7. An expression is mentioned as follows. Figure out number of incorrect
notations or symbols, such that a change in those could make the
expression correct.
L(G)={w in T*|S→*w}
a) 0 Errors
b) 1 Error
c) 2 Error
d) Invalid Expression
View Answer
Answer: a
Explanation: For the given expression, L(G)={w in T*|S→*w}, If G(V, T, P,
S) is a CFG, the language of G, denoted by L(G), is the set of terminal
strings that have derivations from the start symbol.
8. The language accepted by Push down Automaton:
a) Recursive Language
b) Context free language
c) Linearly Bounded language
d) All of the mentioned
View Answer
Answer: b
Explanation: Push down automata accepts context free language.
9. Which among the following is the correct option for the given grammar?
G->X111|G1,X->X0|00
a) {0a1b|a=2,b=3}
b) {0a1b|a=1,b=5}
c) {0a1b|a=b}
d) More than one of the mentioned is correct
View Answer
Answer: a
Explanation: Using the recursive approach, we can conclude that option a
is the correct answer, and its not possible for a grammar to have more than
one language.
10. Which of the following the given language belongs to?
L={ambmcm| m>=1}
a) Context free language
b) Regular language
c) Context free language & Regular language
d) None of the mentioned
View Answer
Answer: d
Explanation: The given language is neither accepted by a finite automata or
a push down automata. Thus, it is neither a context free language nor a
regular language.
11. Choose the correct option:
Statement: There exists two inference approaches: Recursive Inference &
Derivation
a) true
b) partially true
c) false
d) none of the mentioned
View Answer
Answer: a
Explanation: We apply the productions of a CFG to infer that certain strings
are in a language of certain variable.
12. Choose the correct option:
Statement 1: Recursive Inference, using productions from head to body.
Statement 2: Derivations, using productions from body to head.
a) Statement 1 is true and Statement 2 is true
b) Statement 1 and Statement 2, both are false
c) Statement 1 is true and Statement 2 is false
d) Statement 2 is true and Statement 1 is true
View Answer
Answer: b
Explanation: Both statements are false. Recursive Inference, using
productions from body to head. Derivations, using productions from head to
body.
13. Which of the following statements are correct for a concept called
inherent ambiguity in CFL?
a) Every CFG for L is ambiguous
b) Every CFG for L is unambiguous
c) Every CFG is also regular
d) None of the mentioned
View Answer
Answer: a
Explanation: A CFL L is said to be inherently ambiguous if every CFG for L
is ambiguous.
14. Which of the theorem defines the existence of Parikhs theorem?
a) Parikh’s theorem
b) Jacobi theorem
c) AF+BG theorem
d) None of the mentioned
View Answer
Answer: a
Explanation: Rohit Parikh in 1961 proved in his MIT research paper that
some context free language can only have ambiguous grammars.
1. State true or false:
Statement: Every right-linear grammar generates a regular language.
a) True
b) False
View Answer
Answer: a
Explanation: A CFG is said to right linear if each production body has at
most one variable, and that variable is at the right end. That is, all
productions of a right linear grammar are of the form A->wB or A->w, where
A and B are variables while w is some terminal.
2. What the does the given CFG defines?
S->aSbS|bSaS|e and w denotes terminal
a) wwr
b) wSw
c) Equal number of a’s and b’s
d) None of the mentioned
View Answer
Answer: c
Explanation: Using the derivation approach, we can conclude that the given
grammar produces a language with a set of string which have equal
number of a’s and b’s.
3. If L1 and L2 are context free languages, which of the following is context
free?
a) L1*
b) L2UL1
c) L1.L2
d) All of the mentioned
View Answer
Answer: d
Explanation: The following is a theorem which states the closure property
of context free languages which includes Kleene operation, Union
operation and Dot operation.
Sanfoundry Certification Contest of the Month is Live. 100+ Subjects.
Participate Now!
advertisement
Explanation:
Check this: Computer Science Books | Automata Theory Books
6. The number of leaves in a parse tree with expression E*(E) where * and
() are operators
a) 5
b) 2
c) 4
d) 3
View Answer
Answer: a
Explanation:
7. Which of the following does the given parse tree correspond to?
a) P->1100
b) P->0110
c) P->1100ε
d) P->0101
View Answer
Answer: b
Explanation: The following is a parse tree for the production 0110 over
{0,1}*.
8. A grammar with more than one parse tree is called:
a) Unambiguous
b) Ambiguous
c) Regular
d) None of the mentioned
View Answer
Answer: b
Explanation: A context free grammar G is ambiguous if there is at least one
string in L(G) having two or more distinct derivation trees or equivalently,
two or more distinct leftmost derivations.
9. __________ is the acyclic graphical representation of a grammar.
a) Binary tree
b) Oct tree
c) Parse tree
d) None of the mentioned
View Answer
Answer: c
Explanation: In order to graphically represent a derivation of a grammar we
need to use parse trees.
10. Grammar is checked by which component of compiler?
a) Scanner
b) Parser
c) Semantic Analyzer
d) None of the mentioned
View Answer
Answer: b
Explanation: Parser or syntax analyzer is the one responsible for checking
the grammar and reporting errors. In this phase, parse tree is generated
and syntax is analyzed.
1. A symbol X is ________ if there exists : S->* aXb
a) reachable
b) generating
c) context free
d) none of the mentioned
View Answer
Answer: a
Explanation: A symbol X is generating if there exists : X->*w for some w
that belongs to T*.
Also, a symbol can never be context free.
2. A symbol X is called to be useful if and only if its is:
a) generating
b) reachable
c) both generating and reachable
d) none of the mentioned
View Answer
Answer: c
Explanation: For a symbol X to be useful, it has to be both reachable and
generating i.e.
S->* aXb -> * w where w belongs to T*.
3. Which of the following is false for a grammar G in Chomsky Normal
Form:
a) G has no useless symbols
b) G has no unit productions
c) G has no epsilon productions
d) None of the mentioned
View Answer
Answer: d
Explanation: G, a CFG is said to be in Chomsky normal form if all its
productions are in one of the following form:
A->BC or A->a
Sanfoundry Certification Contest of the Month is Live. 100+ Subjects.
Participate Now!
advertisement
4. Given Checklist:
i) G has no useless symbols
ii) G has no unit productions
iii) G has no epsilon productions
iv) Normal form for production is violated
Is it possible for the grammar G to be in CNF with the following checklist?
a) Yes
b) No
View Answer
Answer: b
Explanation: The grammar is not in CNF if it violates the normal form of the
productions which is strictly restricted.
5. State true or false:
Statement: A CNF parse tree’s string yield (w) can no longer be 2h-1.
a) true
b) false
View Answer
Answer: a
Explanation: It is the parse tree theorem which states:
Given: Suppose we have a parse tree for a string w, according to a CNF
grammar, G=(V, T, P, S). Let h be the height of the parse tree. Now,
Implication: |w|<=2h-1.
Check this: Computer Science MCQs | Automata Theory Books
6. If |w|>=2h, then its parse tree’s height is at least _____
a) h
b) h+1
c) h-1
d) 2h
View Answer
Answer: b
Explanation: It is the basic implication of Parse tree theorem (assuming
CNF). If the height of the parse tree is h, then |w| <=2h-1.
7. If w belongs to L(G), for some CFG, then w has a parse tree, which tell
us the ________ structure of w.
a) semantic
b) syntactic
c) lexical
d) all of the mentioned
View Answer
Answer: b
Explanation: A parse tree or concrete syntactic tree is an ordered, rooted
tree that represents the syntactic structure of a string according to some
context free grammar.
8. Which of the following are distinct to parse trees?
a) abstract parse trees
b) sentence diagrams
c) both abstract parse trees and sentence diagrams
d) none of the mentioned
View Answer
Answer: c
Explanation: Both of the mentioned are different from parse trees.
Sentence diagrams are pictorial representations of grammatical structure of
a sentence.
9. Choose the correct option:
Statement: Unambiguity is the ideal structure of a language.
a) true
b) partially true
c) false
d) cant be said
View Answer
Answer: a
Explanation: Ideally, there should be only one parse tree for each string,
i.e. the language should be unambiguous.
10. Is the given statement correct?
Statement: The mere existence of several derivations is not an issue, its is
the existence of several parse trees that ruins a grammar.
a) Yes
b) No
View Answer
Answer: a
Explanation: It is also true that multiple leftmost or rightmost derivations do
cause ambiguity. Unfortunately, it is not possible to remove the ambiguity
always.
1. To derive a string using the production rules of a given grammar, we
use:
a) Scanning
b) Parsing
c) Derivation
d) All of the mentioned
View Answer
Answer: b
Explanation: Parsing is required to check the acceptability of a string.
Further, comes the syntactical phase which is taken care by other phases
of compiler.
2. Which of the following parser reaches the root symbol of the tree at last?
a) Top down parser
b) Bottom up parser
c) TOP down and Bottom up parser
d) None of the mentioned
View Answer
Answer: b
Explanation: Bottom up parser starts from the bottom with the string and
comes up to the start symbolusing a parse tree or a derivation tree.
3. Left corner parsing methof uses which of the following?
a) Top down parser
b) Bottom up parser
c) TOP down and Bottom up parser
d) None of the mentioned
View Answer
Answer: c
Explanation: It is a hybrid method which works bottom up along the left
edges of each subtree, and top down on the rest of the parse tree.
Note: Join free Sanfoundry classes at Telegram or Youtube
advertisement
a) {0n1n|n>=0}
b) {0n12n|n>=0}
c) {02n1n|n>=0}
d) None of the mentioned
View Answer
Answer: a
Explanation: None.
Note: Join free Sanfoundry classes at Telegram or Youtube
advertisement
a) {wwr|w=(a+b)*}
b) ε is called the initial stack symbol
c) All of the mentioned
d) None of the mentioned
View Answer
Answer: a
Explanation: Initially we put a special symbol ‘#’ into the empty stack. At
state q1, the w is being read. In state q2, each 0 or 1 is popped when it
matches the input. If any other input is given, the PDA will go to a dead
state. When we reach that special symbol ‘#’, we go to the accepting state
q3.
5. Which of the following assertion is false?
a) If L is a language accepted by PDA1 by final state, there exist a PDA2
that accepts L by empty stack i.e. L=L(PDA1)=L(PDA2)
b) If L is a CFL then there exists a push down automata P accepting CF; by
empty stack i.e. L=M(P)
c) Let L is a language accepted by PDA1 then there exist a CFG X such
that L(X)=M(P)
d) All of the mentioned
View Answer
Answer: d
Explanation: All the assertions mentioned are theorems or corollary.
Check this: Automata Theory Books | Computer Science Books
6. A push down automata can represented using:
a) Transition graph
b) Transition table
c) ID
d) All of the mentioned
View Answer
Answer: d
Explanation: Yes, a PDA can be represented using a transition diagram,
transition table and an instantaneous description.
7. State true or false:
Statement: Every context free grammar can be transformed into an
equvalent non deterministic push down automata.
a) true
b) false
View Answer
Answer: a
Explanation: Push down automata is the automaton machine for all the
context free grammar or Type 2 languages.
8. Which of the following statement is false?
a) For non deterministic PDA, equivalence is undecidable
b) For deterministic PDA, equivalence is decidable
c) For deterministic PDA, equivalence is undecidable
d) None of the mentioned
View Answer
Answer: c
Explanation: Geraud proved the equivalence problem decidable for
Deterministic PDA .
9. Which of the following are the actions that operates on stack top?
a) Pushing
b) Popping
c) Replacing
d) All of the mentioned
View Answer
Answer: d
Explanation: Push, pop and replace are all the basic and only operations
that takes place on stack top.
10. A push down automata is said to be _________ if it has atmost one
transition around all configurations.
a) Finite
b) Non regular
c) Non-deterministic
d) Deterministic
View Answer
Answer: d
Explanation: DPDA or Deterministic Push down automata has atmost one
transition applicable to each configuration.
1. The transition a Push down automaton makes is additionally dependent
upon the:
a) stack
b) input tape
c) terminals
d) none of the mentioned
View Answer
Answer: a
Explanation: A PDA is a finite machine which has an additional stack
storage. Its transitions are based not only on input and the correct state but
also on the stack.
2. A PDA machine configuration (p, w, y) can be correctly represented as:
a) (current state, unprocessed input, stack content)
b) (unprocessed input, stack content, current state)
c) (current state, stack content, unprocessed input)
d) none of the mentioned
View Answer
Answer: a
Explanation: A machine configuration is an element of K×Σ*×Γ*.
(p,w,γ) = (current state, unprocessed input, stack content).
3. |-* is the __________ closure of |-
a) symmetric and reflexive
b) transitive and reflexive
c) symmetric and transitive
d) none of the mentioned
View Answer
Answer: b
Explanation: A string w is accepted by a PDA if and only if (s,w, e) |-* (f, e,
e)
Sanfoundry Certification Contest of the Month is Live. 100+ Subjects.
Participate Now!
advertisement
(1) S → aMb
(2) M → e
(3) M → aM
(4) M → bM
b)
(1) S → aMb
(2) M → Mab
(3) M → aM
(4) M → bM
c)
(1) S → aMb
(2) M → e
(3) M → aMb
(4) M → bMa
-> m a i n
-> | epsilon
b)
--> m a i n
-->
c)
--> m a i n
--> | epsilon
1. Suppose A->xBz and B->y, then the simplified grammar would be:
a) A->xyz
b) A->xBz|xyz
c) A->xBz|B|y
d) none of the mentioned
View Answer
Answer: a
Explanation: For the first step, substitute B in first production as it only
produces terminal and remove B production as it has already been utilized.
We get A->xBz|xyz and now, as B has no production, we eliminate the
terms which hold the variable B, thus the answer remain A->xyz.
2. Given Grammar: S->A, A->aA, A->e, B->bA
Which among the following productions are Useless productions?
a) S->A
b) A->aA
c) A->e
d) B->bA
View Answer
Answer: d
Explanation: Some derivations are not reachable from the starting variable.
As B is not reachable from the starting variable, it is a useless symbol and
thus, can be eliminated.
3. Given:
S->…->xAy->…->w
if ____________, then A is useful, else useless symbol.
a) A is a non terminal
b) A is a terminal
c) w Î L
d) w Ë L
View Answer
Answer: c
Explanation: Whatever operation we perform in intermediate stages, if the
string produced belongs to the language, A is termed as useful and if not,
not a useful variable.
Note: Join free Sanfoundry classes at Telegram or Youtube
advertisement
4. Given:
S->aSb
S->e
S-> A
A->aA
B->C
C->D
The ratio of number of useless variables to number of useless production
is:
a) 1
b) 3/4
c) 2/3
d) 0
View Answer
Answer: a
Explanation: A, B, C, D are the useless symbols in the given grammar as
they never tend to lead to a terminal. The productions S-> A, A->aA, B->C,
C->D are also termed as useless production as they will never produce a
string to the grammar.
5. Given grammar G:
S->aS|A|C
A->a
B->aa
C->aCb
Find the set of variables thet can produce strings only with the set of
terminals.
a) {C}
b) {A,B}
c) {A,B,S}
d) None of the mentioned
View Answer
Answer: c
Explanation: First step: Make a set of variables that directly end up with a
terminal
Second step: Modify the set with variables that produce the elements of
above
generated set.
The rest variables are termed as useless.
Check this: Automata Theory Books | Computer Science MCQs
6. Given grammar:
S->aS|A
A->a
B->aa
Find the number of variables reachable from the Starting Variable?
a) 0
b) 1
c) 2
d) None of the mentioned
View Answer
Answer: b
Explanation: Use a dependency graph to find which variable is reachable
and which is not.
7. Inorder to simplify a context free grammar, we can skip the following
operation:
a) Removal of null production
b) Removal of useless symbols
c) Removal of unit productions
d) None of the mentioned
View Answer
Answer: d
Explanation: Inorder to simplify the grammar all of the process including the
removal of null productions, unit productions and useless symbols is
necessary.
8. Given a Grammar G:
S->aA
A->a
A->B
B->A
B->bb
Which among the following will be the simplified grammar?
a) S->aA|aB, A->a, B->bb
b) S->aA|aB, A->B, B->bb
c) S->aA|aB, A->a, B->A
d) None of the emntioned
View Answer
Answer: a
Explanation: Step 1: Substitute A->B
Step 2: Remove B->B
Step 3: Substitute B->A
Step 4: Remove Repeated productions
9. Simplify the given grammar:
A-> a| aaA| abBc
B-> abba| b
4. Given a grammar in GNF and a derivable string in the grammar with the
length n, any ___________will halt at depth n.
a) top-down parser
b) bottom-up parser
c) multitape turing machine
d) none of the mentioned
View Answer
Answer: a
Explanation: Given a grammar in GNF and a derivable string in the
grammar with the length n, any top-down parser will halt at depth n. As the
parameter ‘depth’ is mentioned, we will use a top-down parser. Example-LL
parser.
5. Which of the following grammars is similar to Floyd Normal form?
a) Backus Naur Form
b) Kuroda Normal Form
c) Greibach Normal Form
d) Chomsky Normal Form
View Answer
Answer: a
Explanation: Donald Knuth implied a BNF” syntax in which all definitions
have such a form may be said to be in ”Floyd Normal Form”.
A->B|C
A->BC
A->a
Check this: Computer Science MCQs | Computer Science Books
6. Which among the following can parse a context free grammar?
a) top down parser
b) bottom up parser
c) CYK algorithm
d) all of the mentioned
View Answer
Answer: d
Explanation: We use certain algorithms to parse a context free grammar
which include the most popular CYK algorithm which employs the concept
of bottom up parsing and dynamic parsing.
7. The standard version of CYK algorithm operates only on context free
grammars in the following form:
a) Greibach Normal form
b) Chomsky Normal form
c) Backus Naur form
d) All of the mentioned
View Answer
Answer: b
Explanation: It requires the presence of a context free grammar into
Chomsky Normal form to operate. However, every context free grammar
can be converted into CNF for keeping the sense of grammar equivalent.
8. The __________ running time of CYK is O(n3 .|G|)
where n is the length of the parse string and |G| is the size of the context
free grammar G.
a) worst
b) best
c) average
d) none of the mentioned
View Answer
Answer: a
Explanation: This is the worst case running time of CYK and and this
makes it one of the most efficient algorithms for recognizing general
context free languages in practice.
9. Which of the following is true for Valiants algorithm?
a) an extension of CYK
b) deals with efficient multiplication algorithms
c) matrices with 0-1 entries
d) all of the mentioned
View Answer
Answer: d
Explanation: Valiants algorithm is actually an extention of CYK which even
computes the same parsing table yet he showed another method can be
utilized fro performing this operation.
10. Which among the following is a correct option in format for representing
symbol and expression in Backus normal form?
a) <symbol> ->expression
b) <symbol>::=_expression_
c) <symbol>=<expression>
d) all of the mentioned
View Answer
Answer: b
Explanation: <symbol>::=_expression_ is the correct representation where
<symbol> is a non terminal, and expression consist of one or more
sequence of symbols, more sequence are separated by |, indicating a
choice.
1. Which of the following is not a negative property of Context free
languages?
a) Intersection
b) Complement
c) Intersection and Complement
d) None of the mentioned
View Answer
Answer: c
Explanation: Context free languages are not closed under complement and
intersection. Thus, are called Negative properties.
2. The intersection of context free language and regular language is
_________
a) regular language
b) context free language
c) context sensitive language
d) non of the mentioned
View Answer
Answer: b
Explanation: If a language L1 is regular and L2 is a context free language,
then L1 intersection L2 will result into a context free language.
3. Which of the following is regular?
a) a100b100
b) (a+b)*-{a100b100}
c) a100b100 and (a+b)*-{a100b100}
d) None of the mentioned
View Answer
Answer: c
Explanation: As the language seems to be finite, a dfa can be constructed
for the same, thus is regular.
Sanfoundry Certification Contest of the Month is Live. 100+ Subjects.
Participate Now!
advertisement
1. A turing machine is a
a) real machine
b) abstract machine
c) hypothetical machine
d) more than one option is correct
View Answer
Answer: d
Explanation: A turing machine is abstract or hypothetical machine thought
by mathematician Alan Turing in 1936 capable of simulating any algorithm,
however complicated it is.
2. A turing machine operates over:
a) finite memory tape
b) infinite memory tape
c) depends on the algorithm
d) none of the mentioned
View Answer
Answer: b
Explanation: The turing machine operates on an infinite memory tape
divided into cells. The machine positions its head over the cell and reads
the symbol.
3. Which of the functions are not performed by the turing machine after
reading a symbol?
a) writes the symbol
b) moves the tape one cell left/right
c) proceeds with next instruction or halts
d) none of the mentioned
View Answer
Answer: d
Explanation: After the read head reads the symbol from the input tape, it
performs the following functions:
a) writes a symbol(some model allow symbol erasure/no writing)
b) moves the tape left or right (some models allows no motion)
c) proceeds with subsequent instruction or goes either into accepting
halting state or rejecting halting state.
Subscribe Now: Automata Theory Newsletter | Important Subjects
Newsletters
advertisement
4. ‘a’ in a-machine is :
a) Alan
b) arbitrary
c) automatic
d) None of the mentioned
View Answer
Answer: c
Explanation: The turing machine was invented by Alan turing in 1936. He
named it as a-machine(automatic machine).
5. Which of the problems were not answered when the turing machine was
invented?
a) Does a machine exists that can determine whether any arbitrary
machine on its tape is circular.
b) Does a machine exists that can determine whether any arbitrary
machine on its tape is ever prints a symbol
c) Hilbert Entscheidungs problem
d) None of the mentioned
View Answer
Answer: d
Explanation: Invention of turing machine answered a lot of questions which
included problems like decision problem, etc.) . Alan was able to prove the
properties of computation using such model.
Check this: Computer Science MCQs | Computer Science Books
6. The ability for a system of instructions to simulate a Turing Machine is
called _________
a) Turing Completeness
b) Simulation
c) Turing Halting
d) None of the mentioned
View Answer
Answer: a
Explanation: Turing Completeness the ability for a system of instructions to
simulate a Turing machine. A programming language that is Turing
complete is theoretically capable of expressing all tasks accomplishable by
computers; nearly all programming languages are Turing complete.
7. Turing machine can be represented using the following tools:
a) Transition graph
b) Transition table
c) Queue and Input tape
d) All of the mentioned
View Answer
Answer: d
Explanation: We can represent a turing machine, graphically, tabularly and
diagramatically.
8. Which of the following is false for an abstract machine?
a) Turing machine
b) theoretical model of computer
c) assumes a discrete time paradigm
d) all of the mentioned
View Answer
Answer: d
Explanation: A n abstract machine also known as abstract computer, is a
theoretical model of computer or hardware system in automata theory.
Abstraction in computing process usually assumes a discrete time
paradigm.
9. Fill in the blank with the most appropriate option.
Statement: In theory of computation, abstract machines are often used in
___________ regarding computability or to analyze the complexity of an
algorithm.
a) thought experiments
b) principle
c) hypothesis
d) all of the mentioned
View Answer
Answer: d
Explanation: A thought experiment considers some hypothesis, theory or
principle for the purpose of thinking through its consequences.
10. State true or false:
Statement: RAM model allows random access to indexed memory
locations.
a) true
b) false
View Answer
Answer: a
Explanation: In computer science, Random access machine is an abstract
machine in the general class of register machines. Random access
machine should not be confused with Random access memory.
1. A turing machine that is able to simulate other turing machines:
a) Nested Turing machines
b) Universal Turing machine
c) Counter machine
d) None of the mentioned
View Answer
Answer: b
Explanation: A more mathematically oriented definition with the same
universal nature was introduced by church and turing together called the
Church-Turing thesis(formal theory of computation).
2. Which of the problems are unsolvable?
a) Halting problem
b) Boolean Satisfiability problem
c) Halting problem & Boolean Satisfiability problem
d) None of the mentioned
View Answer
Answer: c
Explanation: Alan turing proved in 1936 that a general algorithm to solve
the halting problem for all possible program-input pairs cannot exist.
3. Which of the following a turing machine does not consist of?
a) input tape
b) head
c) state register
d) none of the mentioned
View Answer
Answer: d
Explanation: A state register is one which stores the state of the turing
machine, one of the finitely many. Among these is the special start state
with which the state register is initialized.
Note: Join free Sanfoundry classes at Telegram or Youtube
advertisement
a) {a}*{b}*{a,b}
b) {a,b}*{aba}
c) {a,b}*{bab}
d) {a,b}*{a}*{b}*
View Answer
Answer: b
Explanation: The given diagram is a transition graph for a turing machine
which accepts the language with the regular expression {a,b}*{aba}.
2. Construct a turing machine which accepts a string with ‘aba’ as its
substring.
a)
b)
c)
d)
View Answer
Answer: c
Explanation: The language consist of strings with a substring ‘aba’ as fixed
at its end and the left part can be anything including epsilon. Thus the
turing machine uses five states to express the language excluding the
rejection halting state which if allowed can modify the graph as:
a) L
b) R
c) S
d) None of the mentioned
View Answer
Answer: c
Explanation: D represents the direction in which automata moves forward
as per the queue which surely cannot be a starting variable.
Check this: Automata Theory Books | Computer Science Books
6. Which of the following can accept even palindrome over {a,b}
a) Push down Automata
b) Turing machine
c) NDFA
d) All of the mentioned
View Answer
Answer: c
Explanation: A language generating strings which are palindrome is not
regular, thus cannot b represented using a finite automaton.
7. Which of the functions can a turing machine not perform?
a) Copying a string
b) Deleting a symbol
c) Accepting a pal
d) Inserting a symbol
View Answer
Answer: d
Explanation: Different turing machines exist for operations like copying a
string, deleting a symbol, inserting a symbol and accepting palindromes.
8. If T1 and T2 are two turing machines. The composite can be represented
using the expression:
a) T1T2
b) T1 U T2
c) T1 X T2
d) None of the mentioned
View Answer
Answer: a
Explanation: If T1 and T2 are TMs, with disjoint sets of non halting states
and transition function d1 and d2, respectively, we write T1T2 to denote
this composite TM.
9. The following turing machine acts like:
a) Copies a string
b) Delete a symbol
c) Insert a symbol
d) None of the mentioned
View Answer
Answer: b
Explanation: A turing machine does the deletion by changing the tape
contents from yaz to yz, where y belongs to (S U {#})*.
10. What does the following transition graph shows:
a) Copies a symbol
b) Reverses a string
c) Accepts a pal
d) None of the mentioned
View Answer
Answer: c
Explanation: The composite TM accepts the language of palindromes over
{a, b} by comparing the input string to its reverse and accepting if and only
if the two are equal.
1. A turing machine has ____________ number of states in a CPU.
a) finite
b) infinte
c) May be finite
d) None of the mentioned
View Answer
Answer: a
Explanation: A turing machine has finite number of states in its CPU.
However, the states are not small in number. Real computer consist of
registers which can store values (fixed number of bits).
2. Suppose we have a simple computer with control unit holding a PC with
a 32 bit address + Arithmetic unit holding one double length 64 bit
Arithmetic Register. The number of states the finite machine will hold:
a) 2(32*64)
b) 296
c) 96
d) 32
View Answer
Answer: b
Explanation: According to the statistics of the question, we will have a finite
machine with 2^96 states.
3. In one move a turing machine will:
a) Change a state
b) Write a tape symbol in the cell scanned
c) Move the tape head left or right
d) All of the mentioned
View Answer
Answer: d
Explanation: A move of a turing machine is the function of the state of finite
control and the tape symbol just scanned.
Sanfoundry Certification Contest of the Month is Live. 100+ Subjects.
Participate Now!
advertisement
4. The complexity class P consist of all the decision problems that can be
solved by ___________using polynomial amount of computation time.
a) Push Down automata
b) DFA
c) NDFA
d) Deterministic Turing machine
View Answer
Answer: d
Explanation: All the decision problems that can be solved using a
Deterministic turing machine using polynomial time to compute, all belong
to the complexity class P.
5. A generalization of P class can be:
a) PTIME
b) DTIME
c) NP
d) None of the mentioned
View Answer
Answer: c
Explanation: P is a specific case of NP class, which is the class of
decidable problems decidable by a non deterministic turing machine that
runs in polynomial time.
Check this: Computer Science Books | Automata Theory Books
6. Which of the following options are correct with reference to P-complete
problems?
a) used for the problems which are difficult to solve in limited space
b) every problem in P can be reduced to it using proper reductions
c) complete problem for complexity class P
d) all of the mentioned
View Answer
Answer: d
Explanation:
The notion of P-complete decision problems is useful in the analysis of:
i) which problems are tough to parallelize effectively
ii) which problems are difficult to solve in limited space
7. A problem X belongs to P complexity class if there exist ________
algorithm to solve that problem, such that the number of steps of the
algorithms bounded by a polynomial in n, where n is the length of the input.
a) 1
b) 2
c) 3
d) all of the mentioned
View Answer
Answer: d
Explanation: A problem X belongs to P complexity class if there exist
atleast 1 algorithm to solve that problem, such that the number of steps of
the algorithms bounded by a polynomial in n, where n is the length of the
input. Thus, all the options are correct.
8. Which of the following is a P-complete type of problem?
a) Circuit Value problem
b) Linear programming
c) Context free grammar membership
d) All of the mentioned
View Answer
Answer: d
Explanation: Given a context free grammar and a string, can the string be
generated by the grammar? Such problems fall in the category of P-
complete.
9. State true or false?
Statement: Given a turing machine, an input for the machine, and a number
T(unary), does that machine halt on that input within the first T-steps?
The given problem is P-complete.
a) true
b) false
View Answer
Answer: a
Explanation: If we can parallelize a general simulation of a sequential
computer, then we will be able to parallelize any program that runs on that
computer. If this problem is in NC, then so every other problem in P.
10. In the above problem, if the input is binary, the class the problem
belongs?
a) EXPSPACE
b) DLOGTIME
c) EXPTIME-complete
d) All of the mentioned
View Answer
Answer: c
Explanation: It is the set of all decision problems that have exponential run
time i.e. solvable by deterministic turing machine in O(2p(n)) time, where p(n)
is a polynomial function of n.
1. What does NP stands for in complexity classes theory?
a) Non polynomial
b) Non-deterministic polynomial
c) All of the mentioned
d) None of the mentioned
View Answer
Answer: b
Explanation: NP is said to be one of the most fundamental complexity
classes. NP is an acronym for Non deterministic polynomial time.
2. The hardest of NP problems can be:
a) NP-complete
b) NP-hard
c) P
d) None of the mentioned
View Answer
Answer: a
Explanation: NP class contains many important problems, the hardest of
which is NP-complete, whose solution is sufficient to deal with any other
NP problem in polynomial time.
3. Which of the following contains NP?
a) PSPACE
b) EXPSPACE
c) Both PSPACE and EXPSPACE
d) None of the mentioned
View Answer
Answer: c
Explanation: It is sufficient to construct a PSPACE machine that loops over
all proof strings and feeds each one to a polynomial time verifier. It is also
contained in EXPTIME, since the same algorithm operates in exponential
time.
Sanfoundry Certification Contest of the Month is Live. 100+ Subjects.
Participate Now!
advertisement
find_a(array A, n, k)
begin
i=0
repeat
Randomly select one element out of n elements
i=i+1
until i=k or a is found
end
a) (1/2)k
b) (1-(1/3))k
c) 1-(1/2)k
d) None of the mentioned
View Answer
Answer: c
Explanation: The given is known as Monte Carlo Algorithm. If a is fount, the
algorithm succeeds, else the algorith fails. The algorithm doesn not
guarantee success but the run time is bounded.
9. Which of the following can be solved in computer science?
a) P=BPP problem
b) NP=co-NP problem
c) Do one way problems exist?
d) All of the mentioned
View Answer
Answer: d
Explanation: There exists a list of unsolved problems in computational
theory which includes many problems including the ones given.
10. Which of the following can be referred to as applications of
Randomized algorithm?
a) Quicksort
b) Min Cut
c) Verifying Matrix Multiplication
d) All of the mentioned
View Answer
Answer: d
Explanation: Freivalds algorithm is a probabalistic randomized algorithm we
use to verify matrix multiplication. On the other hand, Randomness can be
useful in quicksort. If the algorithm selects pivot element uniformaly at
random, it has a probably high probabilty of finishing the work in O(nlogn)
time regardless of the input.
1. Which among the following is smallest for n=50
a) 2n2
b) n2+3n+7
c) n3
d) 2n
View Answer
Answer: b
Explanation:
2n2=5000
n2+3n+7=2567
n3=125000
2n=1.13*1015
2. The space complexity of a turing machine is undefined if:
a) It is a multitape turing machine
b) If no string of length n causes T to use infinite number of tape squares
c) If some input of length n causes T to loop forever
d) None of the mentioned
View Answer
Answer: c
Explanation: If there exists an input string of length n that causes T to use
an infinite number of tape squares, the space complexity of the turing
machine is undefined.
3. In order to reduce the run time of a turing machine:
a) we can reduce the number of tapes
b) we can increase the number of tapes
c) use infinite tapes
d) none of the mentioned
View Answer
Answer: b
Explanation: One way to reduce the run time can be to increase the
number of tapes. Sometimes, using two tapes can be used to avoid back
and forth motions altogether.
Note: Join free Sanfoundry classes at Telegram or Youtube
advertisement
4. Which of the following are basic complexity classes for a function f:N-
>N?
a) Ntime(f)
b) Nspace(f)
c) Space(f)
d) All of the mentioned
View Answer
Answer: d
Explanation: Ntime(f): is a set of languages that can be accepted by a NTM
T with non deterministic time complexity function t <=f. In all four cases, the
machines are allowed to be multitape TM’s.
5. A function f is called __________ if there exists a TM T so that for any n
and any input string of length n, T halts in exactly f(n) moves.
a) Step function
b) Step counting function
c) Inplace functions
d) None of the mentioned
View Answer
Answer: b
Explanation: If f is a step counting function, T is a TM halting in f(n) moves
where n is the length of input string.
Check this: Computer Science MCQs | Computer Science Books
6. Let f: N->N be a step counting function. Then for some constant C,
Time(f) is a proper subset of Time(_______)
a) O(nf)
b) O(n+f)
c) O(n2f2)
d) None of the mentioned
View Answer
Answer: c
Explanation: Using the encoding function, it is possible to show that if the
function f is a step counting function, then the function Cn 2(f(n))2 is the total
number of moves required.
7. Which among the following is false?
If f=O(h) and g=O(k) for f,g,h,k:N->N, then
a) f+g = O(h+k)
b) fg = O(hk)
c) fg=O(hk)
d) None of the mentioned
View Answer
Answer: c
Explanation: f,g,h,k are partial functions and each is defined at all but a
finite number of points.
8. Which of the following is not correct for ZPP?
a) zero error probabalistic polynomial time
b) it runs in non-polynomial time
c) it returns an answer yes, no or do not know
d) none of the mentioned
View Answer
Answer: b
Explanation: ZPP is zero error probabalistic polynomial time complexity
class which run in polynomial time, returns an answer: yes, no or do not
know.
9. ZPP is based on ________
a) Probabalistic turing machine
b) Alternative turing machine
c) Quantum turing machine
d) None of the mentioned
View Answer
Answer: a
Explanation: A probabalistic turing machine is a non deterministic turing
machine which randomly chooses between the available transitions at each
point according to some probability distribution.
10. ZPP is exactly equal to the ____________of the classes RP and co-
RP.
a) Union
b) Intersection
c) Concatenation
d) Difference
View Answer
Answer: b
Explanation: To prove the following statement, we need to take in note that
every problem in RP and co-RP has a Las-Vegas algorithm.
11. Suppose we have a las vegas algorithm C to prove ZPP is contained in
RP and co-RP. Run C for double its expected running time.
By Markov’s inequality, the chance that it will answer before we stop is:
a) 1/2
b) 1/4
c) 1/3
d) none of the mentioned
View Answer
Answer: a
Explanation: This means the chance we’ll give the wrong answer on a YES
instance, by stopping and yielding NO, is only 1/2, fitting the definition of an
RP algorithm.
12. State true or false:
Statement: ZPP is closed under complement function.
a) true
b) false
View Answer
Answer: a
Explanation: ZPP is said to be closed under complement function i.e.
ZPP=co-ZPP.