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. Stack alphabet
B. Set of internal states
C. Transition function
D. Input alphabet

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

A. Queue
B. Linked List
C. Stack
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 unread portion of the input string
B. The contents of the stack
C. The symbols already processed
D. The entire input string

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

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

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

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

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

A. Both acceptance methods describe exactly the same class of languages.
B. Acceptance by empty stack is strictly more powerful.
C. Acceptance by final state is strictly more powerful.
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. No string in is a proper prefix of another string in .
B. The language contains the empty string .
C. Every string in is a prefix of some string in the universal language.
D. All strings in share the same prefix.

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. Duplicating the stack alphabet.
C. Making the initial state the only final state.
D. Removing all -transitions.

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

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

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

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

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

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

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. The stack alphabet must be equal to the input alphabet.
C. It must accept by empty stack.
D. If is not empty, then must be empty for all .

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. The union of variables and terminals of the CFG
C. The states of the PDA
D. Only the terminals of the CFG

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. contains
B.
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. Bottom-up derivation
C. Leftmost derivation
D. Mixed derivation

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

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

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

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

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

A. Yes, but the complement becomes a non-deterministic CFL.
B. Yes, the complement of a DCFL is always a DCFL.
C. No, DCFLs are never closed under complementation.
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 never Context-Free.
B. It is Context-Sensitive but not Context-Free.
C. It is always Context-Free.
D. It is always Regular.

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

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

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

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

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

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

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

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

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

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

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

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

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. FOLLOW() FOLLOW() = .
C. The grammar is ambiguous.
D. FIRST() FIRST() = , and if FIRST(), then FIRST() FOLLOW() = .

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

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

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

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

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

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

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

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

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

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

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

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

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

A. The parser cannot decide which of two distinct productions to reduce by.
B. The parser is instructed to shift multiple tokens simultaneously.
C. The parser reaches the end of the input but the stack is not empty.
D. 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.

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. Must shift the next symbol immediately.
D. Has recognized and is shifting .

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

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

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. CLR(1) and LALR(1) tables always have the exact same number of states.
C. LALR(1) tables have the same number of states as LR(0) tables, which is generally fewer than CLR(1).
D. LALR(1) tables cannot parse Context-Free Grammars.

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

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

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. LR(0) < LALR(1) < SLR(1) < CLR(1)
C. SLR(1) < LR(0) < CLR(1) < LALR(1)
D. CLR(1) < LALR(1) < SLR(1) < LR(0)

42 A grammar that is ambiguous can never be:

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

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 certainly not LALR(1).
B. The parser should shift instead of reducing.
C. The grammar contains left recursion.
D. The grammar is unambiguously LR(0).

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, there are LL(1) grammars that cannot be parsed by LR(1) parsers.
C. Yes, LL(1) and LR(1) are identical sets of grammars.
D. No, LR(1) and LL(1) are disjoint sets of grammars.

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

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

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

A. LL(1) Parsing
B. LR(0) 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 input is successfully accepted.
C. The stack is popped until it is empty.
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 require infinite lookahead to resolve stack operations.
C. They cannot recognize non-deterministic Context-Free Languages like palindromes of even length.
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)