Unit 5 - Practice Quiz

CSE322 50 Questions
0 Correct 0 Wrong 50 Left
0/50

1 A Pushdown Automaton (PDA) is formally defined as a 7-tuple: . What does represent?

A. Input alphabet
B. Set of internal states
C. Stack alphabet
D. Transition function

2 Which fundamental data structure is used in the computational model of a Pushdown Automaton?

A. Queue
B. Stack
C. Linked List
D. Hash Table

3 For a Non-Deterministic Pushdown Automaton (NPDA), the transition function is a mapping defined as:

A.
B.
C.
D.

4 An Instantaneous Description (ID) of a PDA is typically represented by a triplet . What does represent in this notation?

A. The entire input string
B. The unread portion of the input string
C. The contents of the stack
D. The symbols already processed

5 What is the primary effect of an -transition in a Pushdown Automaton?

A. The PDA rejects the input string immediately.
B. The PDA consumes an input symbol but leaves the stack unchanged.
C. The PDA changes its state and/or stack contents without consuming any input symbol.
D. The PDA halts its execution.

6 A PDA accepts a string by 'empty stack' if, after completely reading the input string, the PDA is in:

A. A final state with an empty stack
B. Any state, and the stack is empty
C. A final state, regardless of stack contents
D. The initial state with an empty stack

7 Which of the following statements is true regarding the equivalence of acceptance by empty stack and acceptance by final state for NPDAs?

A. Acceptance by final state is strictly more powerful.
B. Acceptance by empty stack is strictly more powerful.
C. Both acceptance methods describe exactly the same class of languages.
D. They are equivalent only for Deterministic PDAs.

8 If a language is accepted by a DPDA by empty stack, the language must possess the prefix property. What does the prefix property mean?

A. All strings in share the same prefix.
B. No string in is a proper prefix of another string in .
C. Every string in is a prefix of some string in the universal language.
D. The language contains the empty string .

9 When converting a PDA that accepts by empty stack into one that accepts by final state, what is a standard modification?

A. Adding a new start state and a new bottom-of-stack marker.
B. Removing all -transitions.
C. Making the initial state the only final state.
D. Duplicating the stack alphabet.

10 A Pushdown Automaton is equivalent in computational power to which type of grammar?

A. Regular Grammar
B. Context-Free Grammar
C. Context-Sensitive Grammar
D. Unrestricted Grammar

11 How do Deterministic Pushdown Automata (DPDA) and Non-Deterministic Pushdown Automata (NPDA) compare in terms of computational power?

A. They are equivalent in power.
B. DPDA is strictly more powerful than NPDA.
C. NPDA is strictly more powerful than DPDA.
D. Their powers are incomparable.

12 A language is classified as a Deterministic Context-Free Language (DCFL) if and only if:

A. It is accepted by some NPDA by empty stack.
B. It is accepted by some DPDA by final state.
C. It can be generated by an ambiguous grammar.
D. It requires infinite stack memory.

13 Which of the following is a strict condition for a PDA to be considered Deterministic (DPDA)?

A. It must not contain any -transitions.
B. It must accept by empty stack.
C. If is not empty, then must be empty for all .
D. The stack alphabet must be equal to the input alphabet.

14 Which of the following Context-Free Languages is NOT a Deterministic Context-Free Language (DCFL)?

A.
B.
C.
D.

15 When converting a Context-Free Grammar (CFG) to a PDA that accepts by empty stack, the stack alphabet typically consists of:

A. Only the variables (non-terminals) of the CFG
B. Only the terminals of the CFG
C. The union of variables and terminals of the CFG
D. The states of the PDA

16 In the standard top-down construction of a PDA from a CFG, if is a production in the grammar, what is the corresponding PDA transition?

A.
B. contains
C.
D.

17 To simulate a top-down parse, the PDA attempts to construct which type of derivation for the input string?

A. Rightmost derivation
B. Leftmost derivation
C. Bottom-up derivation
D. Mixed derivation

18 Context-Free Languages (CFLs) are unconditionally closed under which of the following operations?

A. Union, Intersection, and Complement
B. Union, Concatenation, and Kleene Star
C. Intersection, Complementation, and Set Difference
D. Symmetric Difference and Intersection

19 Which of the following statements about the intersection of languages is true?

A. The intersection of two CFLs is always a CFL.
B. The intersection of a CFL and a Regular Language is always a CFL.
C. The intersection of two Regular Languages is sometimes a CFL, but not regular.
D. The intersection of a CFL and a Regular Language is always Regular.

20 Are Deterministic Context-Free Languages (DCFLs) closed under complementation?

A. Yes, the complement of a DCFL is always a DCFL.
B. No, DCFLs are never closed under complementation.
C. Yes, but the complement becomes a non-deterministic CFL.
D. No, the complement is only regular.

21 Which of the following is a classic example of a language that is NOT Context-Free?

A.
B.
C.
D.

22 If is a Context-Free Language and is a Regular Language, what can be said about the set difference ?

A. It is always Regular.
B. It is always Context-Free.
C. It is never Context-Free.
D. It is Context-Sensitive but not Context-Free.

23 In parsing terminology, what does the first 'L' in LL(k) signify?

A. Leftmost derivation
B. Left-to-right scan of the input
C. Lexical analysis
D. Lookahead

24 What does the second 'L' in LL(k) parsing signify?

A. Left-to-right scanning
B. Left recursion removal
C. Leftmost derivation
D. Left factoring

25 A grammar contains the production . This grammar is strictly unsuitable for Top-Down LL(k) parsers because it exhibits:

A. Right recursion
B. Ambiguity
C. Left recursion
D. Left factoring

26 What grammar transformation is necessary when productions have common prefixes, such as , to make the grammar LL(1)?

A. Elimination of left recursion
B. Left factoring
C. Right factoring
D. Conversion to Chomsky Normal Form

27 For a non-terminal , the FIRST set is defined as:

A. The set of all terminals that can appear at the end of a string derived from .
B. The set of terminals that can appear immediately to the right of in some sentential form.
C. The set of terminals that begin strings derived from .
D. The set of non-terminals that can derive .

28 For a non-terminal , the FOLLOW set is defined as:

A. The set of terminals that begin strings derived from .
B. The set of terminals that can appear immediately to the right of in some sentential form.
C. The set of variables that follow in a production rule.
D. The set of terminal symbols that can precede .

29 A grammar is confirmed to be LL(1) if and only if, for any pair of productions :

A. FIRST() and FIRST() are identical sets.
B. FIRST() FIRST() = , and if FIRST(), then FIRST() FOLLOW() = .
C. FOLLOW() FOLLOW() = .
D. The grammar is ambiguous.

30 What indicates a failure in making a grammar LL(1) when constructing the LL(1) parse table?

A. The table has blank entries.
B. A single cell in the parsing table contains multiple production rules.
C. Every cell contains exactly one rule.
D. The FIRST and FOLLOW sets have common elements for different non-terminals.

31 A Recursive Descent Parser is a practical implementation of which parsing methodology?

A. Bottom-up Parsing
B. Top-down Parsing
C. Shift-Reduce Parsing
D. Operator Precedence Parsing

32 What does the 'R' in LR(k) parsing signify?

A. Rightmost derivation
B. Right-to-left scanning
C. Rightmost derivation in reverse
D. Recursive descent

33 A bottom-up parser constructs the parse tree by starting from the:

A. Root and growing down to the leaves
B. Leaves and growing up to the root
C. Leftmost child and moving right
D. Start symbol of the grammar

34 In bottom-up parsing, what is a 'handle'?

A. The start symbol of the grammar.
B. A substring that matches the right side of a production and whose reduction represents a step in the reverse rightmost derivation.
C. The left side of a production rule.
D. The current input symbol being scanned.

35 Which parsing action involves pushing the current input symbol onto the stack in an LR parser?

A. Reduce
B. Accept
C. Shift
D. Error

36 What constitutes a 'Shift/Reduce' conflict in bottom-up parsing?

A. The parser is instructed to shift multiple tokens simultaneously.
B. The parser cannot decide which of two distinct productions to reduce by.
C. The parser is in a state where it can either shift the next input symbol or reduce by a production, and the lookahead doesn't resolve the choice.
D. The parser reaches the end of the input but the stack is not empty.

37 An LR(0) item of the form indicates that the parser:

A. Is expecting to see a string derivable from .
B. Has recognized and is ready to reduce it to .
C. Has recognized and is shifting .
D. Must shift the next symbol immediately.

38 How does an SLR(1) parser resolve reduce actions compared to a basic LR(0) parser?

A. It reduces only if the next input symbol is in the FIRST set of the left-hand side non-terminal.
B. It reduces only if the next input symbol is in the FOLLOW set of the left-hand side non-terminal.
C. It looks ahead exactly 2 symbols.
D. It merges states that have identical core items.

39 Which of the following describes the relationship between the number of states in LALR(1) and CLR(1) parsing tables for a given grammar?

A. LALR(1) tables always have more states than CLR(1) tables.
B. LALR(1) tables have the same number of states as LR(0) tables, which is generally fewer than CLR(1).
C. CLR(1) and LALR(1) tables always have the exact same number of states.
D. LALR(1) tables cannot parse Context-Free Grammars.

40 Which parser generator tool prominently uses the LALR(1) parsing technique?

A. Lex
B. Flex
C. YACC / Bison
D. ANTLR

41 Rank the following LR parsers in increasing order of their parsing power (from weakest to strongest).

A. LR(0) < SLR(1) < LALR(1) < CLR(1)
B. SLR(1) < LR(0) < CLR(1) < LALR(1)
C. LR(0) < LALR(1) < SLR(1) < CLR(1)
D. CLR(1) < LALR(1) < SLR(1) < LR(0)

42 A grammar that is ambiguous can never be:

A. Context-Free
B. LL(1) or LR(1)
C. Unrestricted
D. Recognized by an NPDA

43 The string of grammar symbols on the stack of a bottom-up parser is known as a:

A. Viable prefix
B. Handle
C. Lookahead token
D. Sentential suffix

44 If an LALR(1) parser encounters a reduce/reduce conflict during table construction, it implies that:

A. The grammar is unambiguously LR(0).
B. The grammar is certainly not LALR(1).
C. The parser should shift instead of reducing.
D. The grammar contains left recursion.

45 Is every LL(1) grammar also an LR(1) grammar?

A. Yes, the class of LL(1) grammars is a strict subset of LR(1) grammars.
B. No, LR(1) and LL(1) are disjoint sets of grammars.
C. Yes, LL(1) and LR(1) are identical sets of grammars.
D. No, there are LL(1) grammars that cannot be parsed by LR(1) parsers.

46 When converting a Context-Free Grammar to a Pushdown Automaton, the language accepted by the resulting PDA is:

A. Equivalent to the language generated by the CFG.
B. A regular subset of the language generated by the CFG.
C. The complement of the language generated by the CFG.
D. A context-sensitive superset of the CFG's language.

47 Which parsing technique relies heavily on the computation of FIRST and FOLLOW sets?

A. LR(0) Parsing
B. LL(1) Parsing
C. Operator Precedence Parsing
D. CYK Algorithm

48 What happens when an LR parser reaches a configuration where the state is and the lookahead symbol is the end-of-input marker ?

A. A shift error is flagged.
B. The stack is popped until it is empty.
C. The input is successfully accepted.
D. The parser requests more input.

49 Which of the following represents an inherent limitation of Deterministic Pushdown Automata (DPDA)?

A. They cannot recognize any Regular Languages.
B. They cannot recognize non-deterministic Context-Free Languages like palindromes of even length.
C. They require infinite lookahead to resolve stack operations.
D. They are equivalent to finite automata.

50 A shift-reduce parser operates primarily using which two data structures?

A. A Queue for input tokens and a Hash Table for grammar rules
B. A Stack for states/symbols and an Input Buffer for the unread string
C. A Linked List for output and a Tree for lookaheads
D. Two Stacks (one for states, one for input)