Welcome

Labore et dolore magna aliqua. Ut enim ad minim veniam

Select Your Favourite
Category And Start Learning.

COMPILER PREVIOUS YEAR QUESTIONS NTA UGC NET 2014

Here you can get all Compiler Questions of UGC NET Computer Science 2014 with solution and explanation.

Q1. A grammar G is LL(1) if and only if the following conditions hold for two distinct productions A → α | β
I. First (α) ∩ First (β) ≠ {a} where a is some terminal symbol of the grammar.
II. First (α) ∩ First (β) ≠ λ
III. First (α) ∩ Follow(A) = φ if λ є First (β)
(A) I and II (B) I and III
(C) II and III (D) I, II and III

Ans: D
assume
S—> aX |aYb first(aX)= a first(aYb)= a
so there will 2 entries for S in terminal ‘a’ which violates the rule of LL(1) grammar because for every variable and for every terminal there can be at most 1 production .
hence ,their intersection should be ∅
first one statement is correct
second one is true with similar reasoning as for first. now third assume example
1) S–>aSA | ∈
2) A–> C | ∈

now take 2) production first(c)=c
follow(A) = follow(S) = => first(A)= c, ∈ ,$ now the first(c)∩ follow(A)= c means there will be again 2 entries for A in c place that means again violation of LL(1) rules. so first(c)∩ follow(A)= ∅ is true.
hence answer is (D)

Q2. Which of the following suffices to convert an arbitrary CFG to an LL(1) grammar ?
(A) Removing left recursion alone.
(B) Removing the grammar alone
(C) Removing left recursion and factoring the grammar
(D) None of the above

Ans: D The grammar not only need to be free from left recursion and left factoring but also it need to be free from ambiguity


Q3. A shift reduce parser suffers from
(A) shift reduce conflict only
(B) reduce reduce conflict only
(C) both shift reduce conflict and reduce reduce conflict
(D) shift handle and reduce handle conflicts

Ans: C

Both shift reduce conflict and reduce reduce conflict A shift-reduce parser scans and parses the input text in one forward pass over the text, without backing up.

Compiler Questions of UGC NET CS Paper – II December – 2014

Q1. Shift-Reduce parsers perform the following :
(A) Shift step that advances in the input stream by K(K>1) symbols and Reduce step that applies a completed grammar rule to some recent parse trees, joining them together as one tree with a new root symbol.
(B) Shift step that advances in the input stream by one symbol and Reduce step that applies a completed grammar rule to some recent
parse trees, joining them together as one tree with a new root symbol.
(C) Shift step that advances in the input stream by K(K = 2) symbols and Reduce step that applies a completed grammar rule to form a single tree.
(D) Shift step that does not advance in the input stream and Reduce step that applies a completed grammar rule to form a single tree.

Ans: B


Q2. Which of the following is true ?
(A) Canonical LR parser is LR (1) parser with single look ahead terminal
(B) All LR(K) parsers with K > 1 can be transformed into LR(1) parsers.
(C) Both (A) and (B)
(D) None of the above

Ans: C A canonical LR parser or LR(1) parser is an LR(k) parser for k=1, i.e. with a single look-ahead terminal. The special attribute of this parser is that all LR(k) parser’s with k>1 can be transformed into a LR(1) parser.


Q3. In a two-pass assembler, symbol table is
(A) Generated in first pass
(B) Generated in second pass
(C) Not generated at all
(D) Generated and used only in second pass

Ans: A
In first pass it does following things It allocates space for the literals.
It computes the total length of the program.
It builds the symbol table for the symbols and their values

Q4. Debugger is a program that
(A) allows to examine and modify the contents of registers
(B) does not allow execution of a segment of program
(C) allows to set breakpoints, execute a segment of program and display contents of
register
(D) All of the above

Ans: C
Debugger allows to set breakpoints, execute a segment of program and display
contents of register. One of the Debugger name is GDB used under Unix.

Comment List

  • Jyoti kumari says:

    Thanks a lot

Leave a comment

error: Content is protected !!