A directory of Objective Type Questions covering all the Computer Science subjects. Here you can access and discuss Multiple choice questions and answers for various compitative exams and interviews.

11. 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 Report Discuss Too Difficult! Search Google
Answer: (a).Recursive descent parser

12. Consider the grammar with non-terminals N = {S,C,S1 },terminals T={a,b,i,t,e}, with S as the start symbol, and the following set of rules:

S --> iCtSS1|a
S1 --> eS|ϵ
C --> b

The grammar is NOT LL(1) because:
a. it is left recursive
b. it is right recursive
c. it is ambiguous
d. It is not context-free
View Answer Report Discuss Too Difficult! Search Google
Answer: (c).it is ambiguous

13. Consider the following two statements:

P: Every regular grammar is LL(1)
Q: Every regular set has a LR(1) grammar

Which of the following is TRUE?
a. Both P and Q are true
b. P is true and Q is false
c. P is false and Q is true
d. Both P and Q are false
View Answer Report Discuss Too Difficult! Search Google
Answer: (c).P is false and Q is true

14. Consider the following grammar.

S -> S * E
S -> E
E -> F + E
E -> F
F -> id

Consider the following LR(0) items corresponding to the grammar above.

(i) S -> S * .E
(ii) E -> F. + E
(iii) E -> F + .E

Given the items above, which two of them will appear in the same set in the canonical sets-of-items for the grammar?
a. (i) and (ii)
b. (ii) and (iii)
c. (i) and (iii)
d. None of the above
View Answer Report Discuss Too Difficult! Search Google
Answer: (d).None of the above

15. A canonical set of items is given below

S --> L. > R
Q --> R.

On input symbol < the set has
a. a shift-reduce conflict and a reduce-reduce conflict
b. a shift-reduce conflict but not a reduce-reduce conflict
c. a reduce-reduce conflict but not a shift-reduce conflict
d. neither a shift-reduce nor a reduce-reduce conflict
View Answer Report Discuss Too Difficult! Search Google
Answer: (d).neither a shift-reduce nor a reduce-reduce conflict

16. Consider the grammar defined by the following production rules, with two operators ∗ and +

S --> T * P
T --> U | T * U
P --> Q + P | Q
Q --> Id
U --> Id

Which one of the following is TRUE?
a. + is left associative, while ∗ is right associative
b. + is right associative, while ∗ is left associative
c. Both + and ∗ are right associative
d. Both + and ∗ are left associative
View Answer Report Discuss Too Difficult! Search Google
Answer: (b).+ is right associative, while ∗ is left associative

17. Consider the following grammar:

S → FR
R → S | ε
F → id

In the predictive parser table, M, of the grammar the entries M[S, id] and M[R, $] respectively
a. {S → FR} and {R → ε }
b. {S → FR} and { }
c. {S → FR} and {R → *S}
d. {F → id} and {R → ε}
View Answer Report Discuss Too Difficult! Search Google
Answer: (a).{S → FR} and {R → ε }

18. Consider the following translation scheme. S → ER R → *E{print("*");}R | ε E → F + E {print("+");} | F F → (S) | id {print(id.value);} Here id is a token that represents an integer and id.value represents the corresponding integer value. For an input '2 * 3 + 4', this translation scheme prints
a. 2 * 3 + 4
b. 2 * +3 4
c. 2 3 * 4 +
d. 2 3 4+*
View Answer Report Discuss Too Difficult! Search Google
Answer: (d).2 3 4+*

19. The grammar A → AA | (A) | ε is not suitable for predictive-parsing because the grammar is
a. ambiguous
b. left-recursive
c. right-recursive
d. an operator-grammar
View Answer Report Discuss Too Difficult! Search Google
Answer: (b).left-recursive

20. Consider the grammar

E → E + n | E × n | n

For a sentence n + n × n, the handles in the right-sentential form of the reduction are
a. n, E + n and E + n × n
b. n, E + n and E + E × n
c. n, n + n and n + n × n
d. n, E + n and E × n
View Answer Report Discuss Too Difficult! Search Google
Answer: (d).n, E + n and E × n

Page 2 of 6