MauryaHub PYQ Practice

cs4032_2026T2_ET_FN.pdf

Compiler Design · End Term · May 2026 FN

← Course papers · Start practice / exam

Questions and published explanations below are available without starting a test. Some questions may not have a published solution yet.

Question 2 MCQ · 2.0 marks

A programmer writes an expression with mismatched grouping: [[IMAGE:359b4f7928435d09_2_2]] . Which compiler phase detects the missing closing parenthesis?
Source diagram or notation
  1. Lexical Analyzer
  2. Syntax Analyzer (Parser)
  3. Semantic Analyzer
  4. Code Optimizer

A published solution is not available for this question yet.

Question 3 MCQ · 2.0 marks

Why does the Static Single Assignment (SSA) form simplify compiler optimization and dataflow analysis?
  1. It gives each definition a unique SSA name so that every SSA name has exactly one static definition, simplifying def-use chains.
  2. It converts non-deterministic context-free grammars into deterministic parsing tables.
  3. It directly maps high-level syntax into binary machine code without an assembler.
  4. It automatically executes hot code blocks dynamically at runtime.

A published solution is not available for this question yet.

Question 4 MCQ · 2.0 marks

Why do bottom-up LR parser generators (like Bison) handle left-recursive grammar rules efficiently, whereas predictive top-down LL(1) parsers cannot parse them directly?
  1. LR parsers shift input symbols and reduce recognized handles rather than recursively expanding the leftmost nonterminal, so left recursion does not cause infinite recursive expansion.
  2. LR parsers convert left recursion to right recursion at compile time.
  3. Top-down parsers use state-splitting algorithms that eliminate shift actions.
  4. LR parsers construct leftmost derivations.

A published solution is not available for this question yet.

Question 5 MCQ · 2.0 marks

Consider the semantic rules associated with production [[IMAGE:359b4f7928435d09_3_3]] : • [[IMAGE:359b4f7928435d09_3_4]] • [[IMAGE:359b4f7928435d09_3_5]] • [[IMAGE:359b4f7928435d09_3_6]] • [[IMAGE:359b4f7928435d09_3_7]] Which classification accurately describes this Syntax-Directed Definition (SDD)?
Source diagram or notationSource diagram or notationSource diagram or notationSource diagram or notationSource diagram or notation
  1. It is an S-attributed definition because [[IMAGE:359b4f7928435d09_3_8]] is synthesized.
    Source diagram or notation
  2. It is an L-attributed definition because inherited attributes depend only on parent attributes and left-sibling attributes.
  3. It is not L-attributed because [[IMAGE:359b4f7928435d09_3_9]] depends on multiple preceding siblings.
    Source diagram or notation
  4. It contains a cyclic dependency preventing evaluation.

A published solution is not available for this question yet.

Question 6 MCQ · 2.0 marks

A compiler permits implicit widening ( [[IMAGE:359b4f7928435d09_4_10]] ) but reports semantic errors for implicit narrowing conversions ( [[IMAGE:359b4f7928435d09_4_11]] or [[IMAGE:359b4f7928435d09_4_12]] ). Given functions [[IMAGE:359b4f7928435d09_4_13]] and variables [[IMAGE:359b4f7928435d09_4_14]] , which function call compiles without semantic errors?
Source diagram or notationSource diagram or notationSource diagram or notationSource diagram or notationSource diagram or notation
  1. [[IMAGE:359b4f7928435d09_4_15]]
    Source diagram or notation
  2. [[IMAGE:359b4f7928435d09_4_16]]
    Source diagram or notation
  3. [[IMAGE:359b4f7928435d09_4_17]]
    Source diagram or notation
  4. [[IMAGE:359b4f7928435d09_4_18]]
    Source diagram or notation

A published solution is not available for this question yet.

Question 7 MCQ · 2.0 marks

If a compiler designer removes the marker production [[IMAGE:359b4f7928435d09_4_19]] from [[IMAGE:359b4f7928435d09_4_20]] and parses [[IMAGE:359b4f7928435d09_4_21]] while attempting to create the symbol table upon reduction of [[IMAGE:359b4f7928435d09_4_22]] , what semantic- action/symbol-table problem occurs during parsing?
Source diagram or notationSource diagram or notationSource diagram or notationSource diagram or notation
  1. The parser cannot perform any shift actions.
  2. The lexer stops emitting token codes.
  3. Identifiers encountered inside [[IMAGE:359b4f7928435d09_4_23]] attempt to enter their scope records into a symbol table that has not yet been initialized.
    Source diagram or notation
  4. All variable data sizes default to 0 bytes.

A published solution is not available for this question yet.

Question 8 MCQ · 2.0 marks

In a [[IMAGE:359b4f7928435d09_4_24]] loop containing a [[IMAGE:359b4f7928435d09_4_25]] statement, what is the precise control-flow target address to which the [[IMAGE:359b4f7928435d09_4_26]] jump must be backpatched?
Source diagram or notationSource diagram or notationSource diagram or notation
  1. The first instruction of the loop body [[IMAGE:359b4f7928435d09_4_27]] .
    Source diagram or notation
  2. The instruction marking the beginning of the condition evaluation [[IMAGE:359b4f7928435d09_5_28]] .
    Source diagram or notation
  3. The instruction immediately following the [[IMAGE:359b4f7928435d09_5_29]] condition (the loop exit).
    Source diagram or notation
  4. The start of the surrounding function activation block.

A published solution is not available for this question yet.

Question 9 MCQ · 2.0 marks

During compilation of a function body, the compiler encounters a local variable declaration [[IMAGE:359b4f7928435d09_5_30]] inside an inner block, while a parameter named [[IMAGE:359b4f7928435d09_5_31]] exists at the function level. Which statement correctly describes how the symbol table handles this declaration?
Source diagram or notationSource diagram or notation
  1. It emits a fatal redeclaration error because identifier [[IMAGE:359b4f7928435d09_5_32]] already exists in an enclosing table.
    Source diagram or notation
  2. It accepts the declaration into the current inner block table because redeclaration checks examine only the current local scope ( [[IMAGE:359b4f7928435d09_5_33]] ).
    Source diagram or notation
  3. It overwrites the parameter [[IMAGE:359b4f7928435d09_5_34]] in the function-level table.
    Source diagram or notation
  4. It automatically renames the variable to avoid shadowing.

A published solution is not available for this question yet.

Question 10 MCQ · 2.0 marks

What is the defining structural invariant of Static Single Assignment (SSA) form?
  1. Every source variable can only be modified at runtime once during execution.
  2. Every SSA variable name has exactly one static definition in the intermediate representation.
  3. No conditional jumps or loop structures are permitted in the control flow graph.
  4. All variables are allocated exclusively to hardware registers.

A published solution is not available for this question yet.

Question 11 MCQ · 2.0 marks

In Local Value Numbering (LVN), what value number is assigned to a copy statement [[IMAGE:359b4f7928435d09_6_35]] ?
Source diagram or notation
  1. [[IMAGE:359b4f7928435d09_6_36]] is assigned the existing value number of [[IMAGE:359b4f7928435d09_6_37]] ( [[IMAGE:359b4f7928435d09_6_38]] ).
    Source diagram or notationSource diagram or notationSource diagram or notation
  2. A brand new, unique value number is generated for [[IMAGE:359b4f7928435d09_6_39]] .
    Source diagram or notation
  3. [[IMAGE:359b4f7928435d09_6_40]] receives a value number only after an arithmetic operation is performed.
    Source diagram or notation
  4. The value number of [[IMAGE:359b4f7928435d09_6_41]] is reset to null.
    Source diagram or notation

A published solution is not available for this question yet.

Question 12 NAT · 3.0 marks

A lexical analyzer uses standard Lex rules to tokenize an input stream. Code snippet [[IMAGE:359b4f7928435d09_6_42]] Input: [[IMAGE:359b4f7928435d09_6_43]] How many total tokens are produced by the lexical analyzer for this input?
Source diagram or notationSource diagram or notation

    A published solution is not available for this question yet.

    Question 13 NAT · 3.0 marks

    Consider the following expression grammar: [[IMAGE:359b4f7928435d09_7_44]] [[IMAGE:359b4f7928435d09_7_45]] [[IMAGE:359b4f7928435d09_7_46]] How many derivation steps are required in the **rightmost derivation** of the string [[IMAGE:359b4f7928435d09_7_47]] from the start symbol E?
    Source diagram or notationSource diagram or notationSource diagram or notationSource diagram or notation

      A published solution is not available for this question yet.

      Question 14 NAT · 3.0 marks

      Consider the augmented grammar: [[IMAGE:359b4f7928435d09_7_48]] [[IMAGE:359b4f7928435d09_7_49]] [[IMAGE:359b4f7928435d09_8_50]] [[IMAGE:359b4f7928435d09_8_51]] How many total [[IMAGE:359b4f7928435d09_8_52]] items are present in state [[IMAGE:359b4f7928435d09_8_53]] ?
      Source diagram or notationSource diagram or notationSource diagram or notationSource diagram or notationSource diagram or notationSource diagram or notation

        A published solution is not available for this question yet.

        Question 15 NAT · 3.0 marks

        Consider the Boolean expression: [[IMAGE:359b4f7928435d09_8_54]] Using the standard syntax-directed translation with backpatching for Boolean expressions, assume that: • Each relational expression [[IMAGE:359b4f7928435d09_8_55]] generates two consecutive TAC instructions: 1. A conditional jump: [[IMAGE:359b4f7928435d09_8_56]] 2. An unconditional jump: [[IMAGE:359b4f7928435d09_8_57]] • The [[IMAGE:359b4f7928435d09_8_58]] counter gives the address of the next generated instruction. • Initially, [[IMAGE:359b4f7928435d09_8_59]] . • The logical NOT operator [[IMAGE:359b4f7928435d09_8_60]] only swaps the [[IMAGE:359b4f7928435d09_8_61]] and [[IMAGE:359b4f7928435d09_8_62]] and does not generate additional instructions. At which instruction number is the conditional jump for the comparison [[IMAGE:359b4f7928435d09_9_63]] generated?
        Source diagram or notationSource diagram or notationSource diagram or notationSource diagram or notationSource diagram or notationSource diagram or notationSource diagram or notationSource diagram or notationSource diagram or notationSource diagram or notation

          A published solution is not available for this question yet.

          Question 16 MSQ · 3.0 marks

          Consider the Deterministic Finite Automaton (DFA) [[IMAGE:359b4f7928435d09_9_64]] where: • [[IMAGE:359b4f7928435d09_9_65]] • [[IMAGE:359b4f7928435d09_9_66]] • [[IMAGE:359b4f7928435d09_9_67]] • [[IMAGE:359b4f7928435d09_9_68]] The transition function δ is defined as: [[IMAGE:359b4f7928435d09_10_69]] Which of the following strings will be **accepted** by this DFA? (Select all that apply)
          Source diagram or notationSource diagram or notationSource diagram or notationSource diagram or notationSource diagram or notationSource diagram or notation
          1. [[IMAGE:359b4f7928435d09_10_70]]
            Source diagram or notation
          2. [[IMAGE:359b4f7928435d09_10_71]]
            Source diagram or notation
          3. [[IMAGE:359b4f7928435d09_10_72]]
            Source diagram or notation
          4. [[IMAGE:359b4f7928435d09_10_73]]
            Source diagram or notation
          5. [[IMAGE:359b4f7928435d09_10_74]]
            Source diagram or notation

          A published solution is not available for this question yet.

          Question 17 MCQ · 3.0 marks

          Consider the following standard expression grammar: [[IMAGE:359b4f7928435d09_10_75]] [[IMAGE:359b4f7928435d09_10_76]] [[IMAGE:359b4f7928435d09_10_77]] [[IMAGE:359b4f7928435d09_10_78]] [[IMAGE:359b4f7928435d09_10_79]] What is [[IMAGE:359b4f7928435d09_10_80]] ?
          Source diagram or notationSource diagram or notationSource diagram or notationSource diagram or notationSource diagram or notationSource diagram or notation
          1. { +, ), $ }
          2. { *, +, $ }
          3. { +, * }
          4. { ), $ }

          A published solution is not available for this question yet.

          Question 18 MCQ · 3.0 marks

          Given pointer [[IMAGE:359b4f7928435d09_11_81]] of type [[IMAGE:359b4f7928435d09_11_82]] and integer [[IMAGE:359b4f7928435d09_11_83]] , where [[IMAGE:359b4f7928435d09_11_84]] . When translating the pointer arithmetic expression [[IMAGE:359b4f7928435d09_11_85]] , which TAC sequence correctly computes the resulting address?
          Source diagram or notationSource diagram or notationSource diagram or notationSource diagram or notationSource diagram or notation
          1. t1 = ptr * 8 t2 = t1 + k
          2. t1 = k * 8 t2 = ptr + t1
          3. t1 = ptr + k
          4. t1 = k + 8 t2 = ptr + t1

          A published solution is not available for this question yet.

          Question 19 MCQ · 3.0 marks

          Consider the Three-Address Code block: [[IMAGE:359b4f7928435d09_11_86]] Which of the following is the correct set of instruction leaders for basic block partitioning?
          Source diagram or notation
          1. [[IMAGE:359b4f7928435d09_12_87]]
            Source diagram or notation
          2. [[IMAGE:359b4f7928435d09_12_88]]
            Source diagram or notation
          3. [[IMAGE:359b4f7928435d09_12_89]]
            Source diagram or notation
          4. [[IMAGE:359b4f7928435d09_12_90]]
            Source diagram or notation

          A published solution is not available for this question yet.

          Question 20 NAT · 2.0 marks

          A compiler translates the expression [[IMAGE:359b4f7928435d09_12_91]] without optimization or common subexpression elimination. Each binary operation generates exactly one binary arithmetic TAC instruction. How many binary arithmetic TAC instructions are emitted?
          Source diagram or notation

            A published solution is not available for this question yet.

            Question 21 MSQ · 2.0 marks

            Consider the following program with nested declarations: [[IMAGE:359b4f7928435d09_13_92]] Which statements are TRUE regarding the variable bindings?
            Source diagram or notation
            1. Inside the first nested block, [[IMAGE:359b4f7928435d09_13_93]] shadows the parameter [[IMAGE:359b4f7928435d09_13_94]] .
              Source diagram or notationSource diagram or notation
            2. In the second nested block, [[IMAGE:359b4f7928435d09_13_95]] is assigned the value of the parameter [[IMAGE:359b4f7928435d09_13_96]] .
              Source diagram or notationSource diagram or notation
            3. In the second nested block, [[IMAGE:359b4f7928435d09_13_97]] is assigned the value of the global [[IMAGE:359b4f7928435d09_13_98]] .
              Source diagram or notationSource diagram or notation
            4. The two nested blocks share identical symbol table instances.

            A published solution is not available for this question yet.

            Question 22 MSQ · 2.0 marks

            Consider the TAC basic blocks: [[IMAGE:359b4f7928435d09_13_99]] Which of the following statements are correct at the **entry of basic block B2**?
            Source diagram or notation
            1. [[IMAGE:359b4f7928435d09_13_100]] is live at the entry of [[IMAGE:359b4f7928435d09_13_101]] .
              Source diagram or notationSource diagram or notation
            2. [[IMAGE:359b4f7928435d09_13_102]] is live at the entry of [[IMAGE:359b4f7928435d09_13_103]] .
              Source diagram or notationSource diagram or notation
            3. [[IMAGE:359b4f7928435d09_14_104]] is live at the entry of [[IMAGE:359b4f7928435d09_14_105]] .
              Source diagram or notationSource diagram or notation
            4. A variable is defined as live at a program point if its current value may be used along at least one future execution path before being redefined.

            A published solution is not available for this question yet.