UGC NET Paper 2 (Computer Science)Very hard
Consider. I. For an LL(1) grammar, the FIRST sets of a nonterminal's alternative productions must be pairwise disjoint. II. If one alternative can derive epsilon, the FIRST sets of the other alternatives must not intersect FOLLOW of that nonterminal. III. Every LL(1) grammar must be left-recursive. Which are correct?
- A. I and II only
- B. I, II and III
- C. II and III only
- D. I only
Correct answer: A. I and II only
I and II are exactly the standard conditions for constructing a conflict-free predictive parsing table; left recursion makes a grammar unusable for LL(1) parsing, so III is false.
Practise more UGC NET Computer Science and Applications questionsUGC NET Computer Science and Applications: notes and key points
More UGC NET Computer Science and Applications questions
- For the basic block t1 = a + b; t2 = t1 c; t3 = a + b; t4 = t3 - t2, after building a DAG and eliminating common sub-expressions, the…
- Solve the recurrence relation given by T(n) = 2T(n/2) + n log n, assuming n is a power of 2, for its asymptotic (Theta) bound.
- The recurrence T(n) = 2T(n/2) + n/log n has the solution:
- For T(n) = T(n/2) + T(n/4) + n, the asymptotic solution is:
- The number of structurally distinct binary trees with 5 nodes is:
- The information-theoretic lower bound on the number of comparisons needed to sort 5 distinct elements is: