🇮🇳 UGC NET Computer Science · subject

UGC NET Computer Science Theory of Computation and Compilers Syllabus

The Theory of Computation and Compilers syllabus for UGC NET Computer Science in full: 10 chapters and 72 topics, every one listed below, plus 70 Theory of Computation and Compilers flashcards with answers.

10Chapters
72Topics
70Flashcards

Theory of Computation and Compilers syllabus: all 10 chapters

Expand any chapter to see its topics and sub-topics.

  1. Theory of Computation

    4 topics
    • Formal Language
    • Non-Computational Problems
    • Diagonal Argument
    • Russel's Paradox
  2. Regular Language Models

    10 topics
    • Deterministic Finite Automaton (DFA)
    • Non-Deterministic Finite Automaton (NDFA)
    • Equivalence of DFA and NDFA
    • Regular Languages
    • Regular Grammars
    • Regular Expressions
    • Properties of Regular Language
    • Pumping Lemma
    • Non-Regular Languages
    • Lexical Analysis
  3. Context Free Language

    9 topics
    • Pushdown Automaton (PDA)
    • Non-Deterministic Pushdown Automaton (NPDA)
    • Context Free Grammar
    • Chomsky Normal Form
    • Greibach Normal Form
    • Ambiguity
    • Parse Tree Representation of Derivation Trees
    • Equivalence of PDA’s and Context Free Grammars
    • Properties of Context Free Language
  4. Turing Machines (TM)

    8 topics
    • Standard Turing Machine and its Variations
    • Universal Turing Machines
    • Models of Computation and Church-Turing Thesis
    • Recursive and Recursively-Enumerable Languages
    • Context-Sensitive Languages
    • Unrestricted Grammars
    • Chomsky Hierarchy of Languages
    • Construction of TM for Simple Problems
  5. Unsolvable Problems and Computational Complexity

    6 topics
    • Unsolvable Problem
    • Halting Problem
    • Post Correspondence Problem
    • Unsolvable Problems for Context-Free Languages
    • Measuring and Classifying Complexity
    • Tractable and Intractable Problems
  6. Syntax Analysis

    9 topics
    • Associativity
    • Precedence
    • Grammar Transformations
    • Top Down Parsing
    • Recursive Descent Predictive Parsing
    • LL(1) Parsing
    • Bottom up Parsing
    • LR Parser
    • LALR(1) Parser
  7. Semantic Analysis

    7 topics
    • Attribute Grammar
    • Syntax Directed Definitions
    • Inherited and Synthesized Attributes
    • Dependency Graph
    • Evaluation Order
    • S-attributed and L-attributed Definitions
    • Type-Checking
  8. Run Time System

    6 topics
    • Storage Organization
    • Activation Tree
    • Activation Record
    • Stack Allocation of Activation Records
    • Parameter Passing Mechanisms
    • Symbol Table
  9. Intermediate Code Generation

    6 topics
    • Intermediate Representations
    • Translation of Declarations
    • Assignments
    • Control Flow
    • Boolean Expressions
    • Procedure Calls
  10. Code Generation and Code Optimization

    7 topics
    • Control-flow Analysis
    • Data-flow Analysis
    • Local Optimization
    • Global Optimization
    • Loop Optimization
    • Peep-Hole Optimization
    • Instruction Scheduling

UGC NET Computer Science Theory of Computation and Compilers flashcards — 70 questions with answers

  1. What formally defines a Deterministic Finite Automaton (DFA)?

    A 5-tuple (Q, Σ, δ, q0, F) where Q is a finite set of states, Σ the input alphabet, δ: Q×Σ→Q the transition function, q0 the start state, and F⊆Q the set of accepting states. For each state-symbol pair there is exactly one next state.

  2. How does a Non-Deterministic Finite Automaton (NDFA/NFA) differ from a DFA in its transition function?

    In an NFA the transition function maps to a set of states: δ: Q×(Σ∪{ε})→2^Q. It allows multiple (or zero) next states and ε-transitions, whereas a DFA has exactly one next state per input symbol.

  3. State the equivalence result between DFA and NFA, and the size relationship via subset construction.

    DFAs and NFAs recognize exactly the same class of languages (regular languages). Any NFA with n states can be converted to an equivalent DFA with up to 2^n states using the subset (powerset) construction.

  4. What is a Regular Language?

    A language that can be accepted by some finite automaton (DFA or NFA), equivalently described by a regular expression or generated by a regular (Type-3) grammar.

  5. What form do productions take in a (right-linear) Regular Grammar?

    Each production is of the form A → aB or A → a (or A → ε), where A,B are non-terminals and a is a terminal. In left-linear grammars the non-terminal appears on the left: A → Ba or A → a.

  6. List the three basic operations of Regular Expressions and their precedence order.

    Union (+ or |), concatenation, and Kleene star (*). Precedence from highest to lowest: star (closure) > concatenation > union. Parentheses override precedence.

  7. Which closure properties hold for Regular Languages?

    Regular languages are closed under union, concatenation, Kleene star, intersection, complement, difference, reversal, and homomorphism. The class is a Boolean algebra (closed under all set operations).

  8. State the Pumping Lemma for Regular Languages.

    For every regular language L there exists a pumping length p such that any string w∈L with |w|≥p can be written as w=xyz where |xy|≤p, |y|≥1, and xy^i z∈L for all i≥0.

  9. How is the Pumping Lemma used to prove a language is non-regular?

    By contradiction: assume L is regular with pumping length p, pick a specific string w∈L with |w|≥p, then show that for every valid decomposition w=xyz some pumped string xy^i z falls outside L, contradicting the lemma.

  10. Give a classic example of a Non-Regular Language and why no DFA accepts it.

    L={a^n b^n | n≥0} is non-regular because a finite automaton has finitely many states and cannot count an unbounded number of a's to match an equal number of b's; the Pumping Lemma confirms this.

  11. What is the role of Lexical Analysis in a compiler?

    The lexical analyzer (scanner) reads the source character stream and groups characters into tokens (lexemes with token types), removes whitespace/comments, and feeds tokens to the parser. Tokens are typically specified by regular expressions and recognized by finite automata.

  12. What formally defines a Pushdown Automaton (PDA)?

    A 7-tuple (Q, Σ, Γ, δ, q0, Z0, F): states Q, input alphabet Σ, stack alphabet Γ, transition δ, start state q0, initial stack symbol Z0, and accepting states F. It is a finite automaton augmented with a stack.

  13. How does the power of a Non-Deterministic PDA (NPDA) compare to a Deterministic PDA (DPDA)?

    NPDAs are strictly more powerful: they accept exactly the context-free languages, while DPDAs accept only the deterministic context-free languages, a proper subset. (For finite automata, determinism makes no difference, but for PDAs it does.)

  14. What is a Context-Free Grammar (CFG)?

    A 4-tuple (V, T, P, S): variables V, terminals T, productions P of the form A→α with A a single variable and α∈(V∪T)*, and start symbol S. CFGs generate exactly the context-free languages.

  15. What are the production restrictions of Chomsky Normal Form (CNF)?

    Every production is of the form A→BC (two variables) or A→a (a single terminal); the only allowed ε-production is S→ε if ε is in the language, and S must not appear on any right-hand side.

  16. What is the production form required by Greibach Normal Form (GNF)?

    Every production is of the form A→aα where a is a single terminal and α is a (possibly empty) string of variables. GNF guarantees each derivation step produces exactly one terminal.

  17. What does it mean for a Context-Free Grammar to be ambiguous?

    A grammar is ambiguous if some string in its language has more than one distinct parse (derivation) tree, equivalently more than one leftmost (or rightmost) derivation.

  18. What is a Parse Tree (derivation tree) and what does its yield represent?

    A parse tree is an ordered tree whose root is the start symbol, internal nodes are variables, and leaves are terminals or ε; it graphically depicts a derivation. Its yield (left-to-right concatenation of leaves) is the derived terminal string.

  19. State the equivalence between PDAs and Context-Free Grammars.

    A language is context-free if and only if it is accepted by some pushdown automaton. Every CFG can be converted to an equivalent PDA and every PDA to an equivalent CFG.

  20. Which closure properties hold (and fail) for Context-Free Languages?

    CFLs are closed under union, concatenation, Kleene star, homomorphism, and reversal, but NOT closed under intersection or complement. (Intersection of a CFL with a regular language is, however, context-free.)

Show the other 50 Theory of Computation and Compilers flashcards
  1. What defines a standard Turing Machine?

    A 7-tuple (Q, Σ, Γ, δ, q0, B, F) with a semi-infinite/infinite tape, tape alphabet Γ (including blank B), transition δ: Q×Γ→Q×Γ×{L,R} that writes a symbol and moves the head left or right. It is the standard model of effective computation.

  2. Name common Turing Machine variations and state their computational power.

    Multi-tape, multi-track, non-deterministic, two-way infinite tape, and multi-dimensional Turing machines. All are equivalent in power to the standard single-tape deterministic TM (they recognize exactly the recursively enumerable languages).

  3. What is a Universal Turing Machine (UTM)?

    A Turing machine U that takes as input an encoding of an arbitrary TM M and an input w, and simulates M on w. It demonstrates that a single machine can compute any computable function—the theoretical basis of the stored-program computer.

  4. State the Church-Turing Thesis.

    Any function that is effectively (algorithmically) computable can be computed by a Turing machine. It equates the intuitive notion of an algorithm with TM computability; it is a thesis (not a provable theorem).

  5. Distinguish Recursive from Recursively Enumerable languages.

    A recursive (decidable) language has a TM that halts on every input, accepting or rejecting (a total decider). A recursively enumerable (r.e.) language has a TM that halts and accepts strings in the language but may loop forever on strings not in it. Recursive ⊊ r.e.

  6. What characterizes Context-Sensitive Languages and the grammars/automata for them?

    They are generated by context-sensitive (Type-1) grammars with non-contracting productions α→β where |α|≤|β| (allowing S→ε if S unused on RHS), and accepted by Linear Bounded Automata (LBAs)—TMs whose tape is bounded by the input length.

  7. What are Unrestricted (Type-0) Grammars and what languages do they generate?

    Grammars whose productions α→β have α containing at least one variable with no other restriction. They generate exactly the recursively enumerable languages and are equivalent in power to Turing machines.

  8. State the Chomsky Hierarchy of grammars, languages, and their machines.

    Type-0: unrestricted → recursively enumerable → Turing machine. Type-1: context-sensitive → CSL → linear bounded automaton. Type-2: context-free → CFL → pushdown automaton. Type-3: regular → regular language → finite automaton. Each class properly contains the next.

  9. What is the Halting Problem and what is its decidability status?

    The Halting Problem asks whether an arbitrary TM M halts on input w. It is undecidable—no algorithm can decide it for all (M,w)—though it is recursively enumerable (semi-decidable).

  10. What is a Diagonalization (Diagonal) Argument used to prove?

    A technique (Cantor's) that constructs an object differing from every item in an enumeration along the diagonal. It proves the reals are uncountable and, in computability, that the set of languages is uncountable while TMs are countable—so some languages are not recursively enumerable, and that the Halting Problem is undecidable.

  11. What is Russell's Paradox and its significance?

    Consider the set R of all sets that do not contain themselves; asking whether R∈R yields a contradiction either way. It exposed inconsistency in naive set theory, motivating axiomatic set theory and highlighting limits of self-reference relevant to undecidability.

  12. What is the Post Correspondence Problem (PCP)?

    Given two lists of strings A=(a1,…,an) and B=(b1,…,bn), decide whether there is a sequence of indices i1…ik such that a_{i1}…a_{ik}=b_{i1}…b_{ik}. PCP is undecidable and is widely used to prove other undecidability results.

  13. Name two undecidable problems for Context-Free Grammars/Languages.

    Undecidable for CFGs: whether a grammar is ambiguous, whether two CFGs generate the same language (equivalence), whether L(G1)∩L(G2)=∅, whether a CFL equals Σ*, and whether a CFL is regular. (Membership and emptiness, however, ARE decidable.)

  14. What is the difference between Tractable and Intractable problems?

    Tractable problems are solvable in polynomial time (class P). Intractable problems require super-polynomial (e.g., exponential) time in the worst case; NP-complete problems are believed intractable since no polynomial algorithm is known (P vs NP open).

  15. Why does operator Associativity matter in grammar design, and how is left-associativity encoded?

    Associativity fixes grouping for operators of equal precedence (e.g., a−b−c = (a−b)−c). Left-associativity is encoded with left-recursive rules like E→E−T | T; right-associativity uses right recursion like E→T=E | T.

  16. How is operator Precedence expressed in an expression grammar?

    By using a separate non-terminal level for each precedence tier, with lower-precedence operators higher in the grammar. E.g., E→E+T|T (addition), T→T*F|F (multiplication, binds tighter), F→(E)|id.

  17. List the standard Grammar Transformations needed for top-down parsing.

    Elimination of left recursion (A→Aα|β becomes A→βA', A'→αA'|ε) and left factoring (A→αβ1|αβ2 becomes A→αA', A'→β1|β2). These remove left recursion and common prefixes that block predictive parsing.

  18. What characterizes Top-Down Parsing?

    It builds the parse tree from the root (start symbol) down to the leaves, performing a leftmost derivation. It includes recursive-descent and predictive LL parsers; it cannot directly handle left-recursive grammars.

  19. What is Recursive Descent Predictive Parsing?

    A top-down method with one (possibly recursive) procedure per non-terminal that consumes input to match productions. The predictive (non-backtracking) form uses lookahead to choose the correct production deterministically.

  20. What conditions make a grammar LL(1)?

    For every non-terminal with productions A→α|β: FIRST(α)∩FIRST(β)=∅, and if β⇒*ε then FIRST(α)∩FOLLOW(A)=∅. Equivalently the LL(1) parsing table has no multiply-defined entries. LL(1) grammars are unambiguous and non-left-recursive.

  21. How are FIRST and FOLLOW sets used in LL(1) parsing?

    FIRST(α) = set of terminals beginning strings derivable from α (plus ε if α⇒*ε). FOLLOW(A) = terminals that can appear immediately after A. The table entry M[A,a] holds A→α when a∈FIRST(α), and when ε∈FIRST(α), for each b∈FOLLOW(A).

  22. What characterizes Bottom-Up Parsing?

    It constructs the parse tree from leaves up to the root by reducing handles, producing a rightmost derivation in reverse. Shift-reduce parsers (LR family) are bottom-up and handle a larger class of grammars than top-down parsers.

  23. Compare the LR parser variants SLR(1), LR(1)/CLR, and LALR(1) by power and table size.

    Power: LR(1) > LALR(1) > SLR(1) > LL(1). LR(1)/CLR has the most states (largest tables); LALR(1) merges LR(1) states with identical cores giving the same number of states as SLR but more power (can introduce reduce-reduce conflicts); SLR uses FOLLOW sets and is simplest but weakest of the LR family.

  24. What are the four actions of an LR shift-reduce parser?

    Shift (push the input symbol and a state), Reduce (pop the handle and apply a production), Accept (successful parse), and Error. Decisions use the parsing tables ACTION (terminals) and GOTO (non-terminals).

  25. What is an Attribute Grammar?

    A context-free grammar augmented with attributes attached to grammar symbols and semantic rules (associated with productions) that compute attribute values. It formalizes the static semantics and syntax-directed translation of a language.

  26. Distinguish Synthesized from Inherited attributes.

    A synthesized attribute of a node is computed from attributes of its children (information flows up the parse tree). An inherited attribute is computed from attributes of its parent and/or siblings (information flows down/sideways).

  27. Define S-attributed and L-attributed Syntax-Directed Definitions.

    S-attributed: uses only synthesized attributes; evaluable bottom-up in a single pass (suits LR parsing). L-attributed: each inherited attribute of a symbol depends only on attributes of its parent and the siblings to its left (plus any synthesized); evaluable in one left-to-right depth-first pass.

  28. What is a Dependency Graph and how does it determine Evaluation Order?

    A directed graph whose nodes are attribute instances and whose edges go from each attribute to those that depend on it. A valid evaluation order is any topological sort of this graph; a cycle means no valid evaluation order exists.

  29. What does Type Checking accomplish in semantic analysis?

    It verifies that operations are applied to operands of compatible types using the language's type rules, performs type inference and coercion/conversion where allowed, and reports type errors. It is typically implemented with synthesized type attributes via syntax-directed definitions.

  30. What is an Activation Record (stack frame) and what does it typically contain?

    A block of memory for one procedure activation containing: return value, actual parameters, control link (to caller's frame), access/static link, saved machine status (return address, registers), and local/temporary variables.

  31. What is an Activation Tree and how does stack allocation relate to it?

    An activation tree depicts the nesting of procedure calls during execution (root = main, children = called procedures). Because calls follow last-in-first-out nesting, activation records are pushed/popped on a run-time stack, mirroring a depth-first traversal of the tree.

  32. Compare call-by-value, call-by-reference, and call-by-name parameter passing.

    Call-by-value: the actual's value is copied; callee changes don't affect the caller. Call-by-reference: the actual's address is passed; callee changes affect the caller's variable. Call-by-name: the actual is re-evaluated (textually substituted) on each use. Call-by-value-result copies in and copies the result back on return.

  33. What information does a compiler Symbol Table store and why?

    For each identifier it stores name, type, scope, storage/offset, kind (variable, function, parameter), and other attributes. It supports semantic analysis (type checking, scope resolution) and code generation; it is typically implemented as a hash table with scope handling.

  34. Name common Intermediate Representations used in compilers.

    Three-address code (e.g., quadruples, triples, indirect triples), syntax trees / DAGs, postfix notation, and static single-assignment (SSA) form. IRs decouple the front end from the back end and ease optimization.

  35. How is a Boolean expression translated using short-circuit (jumping) code?

    Boolean operators are translated into conditional jumps rather than computing 0/1 values: for a&&b, if a is false jump to the false-exit; for a||b, if a is true jump to the true-exit. Backpatching fills in jump targets (truelist/falselist) once labels are known. This realizes short-circuit evaluation.

  36. How is an if-then-else / control-flow statement translated to three-address code?

    The boolean condition is given true and false target labels; code emits a conditional jump to the false label, the then-block, a jump past the else, the false label, then the else-block, then the merge label. Loops (while) similarly use a begin label, condition test, body, and a jump back.

  37. What is the distinction between Local Optimization and Global Optimization?

    Local optimization works within a single basic block (e.g., common-subexpression elimination, constant folding using a DAG). Global optimization spans basic blocks across the whole procedure using control-flow and data-flow analysis (e.g., global CSE, code motion).

  38. What is Data-Flow Analysis and name two classic problems with their direction.

    It gathers information about how data values propagate through a program's control-flow graph by solving equations to a fixed point. Reaching definitions and available expressions are forward problems; live variable analysis and very-busy expressions are backward problems.

  39. What is Control-Flow Analysis and what is a basic block?

    Control-flow analysis builds the control-flow graph (CFG) and identifies loops and dominators. A basic block is a maximal sequence of consecutive instructions with one entry (a leader) and one exit—no branches in except at the start and none out except at the end.

  40. Describe Loop Optimization techniques.

    Loop-invariant code motion (hoist computations that don't change out of the loop), induction-variable elimination/strength reduction (replace expensive ops like multiply with add), and loop unrolling. These reduce work performed per iteration; they target the most frequently executed code.

  41. What is Peephole Optimization?

    A machine-dependent technique that examines a small sliding window (peephole) of target/intermediate instructions and replaces inefficient sequences with shorter/faster ones: removing redundant loads/stores, eliminating unreachable code, algebraic simplification, strength reduction, and using machine idioms.

  42. What is Instruction Scheduling and why is it performed?

    Reordering instructions to improve performance on pipelined/superscalar processors—filling delay slots, avoiding pipeline stalls, and hiding memory/functional-unit latencies—while preserving data dependences. List scheduling over a dependence DAG is a common approach.

  43. What is a Non-Computational (undecidable) problem, with an example?

    A problem for which no algorithm (Turing machine) can produce the correct yes/no answer for all inputs. Examples: the Halting Problem, the Post Correspondence Problem, and determining whether two CFGs are equivalent.

  44. How is the Halting Problem's undecidability typically proven?

    By diagonalization/contradiction: assume a decider H(M,w) exists; build D(M) that halts iff H says M loops on M; then D(D) halts iff it loops—a contradiction. Hence no such H exists and halting is undecidable.

  45. How are complexity classes P and NP defined?

    P is the class of decision problems solvable by a deterministic TM in polynomial time. NP is the class solvable by a non-deterministic TM in polynomial time, equivalently problems whose 'yes' certificates are verifiable in polynomial time. P⊆NP; whether P=NP is open.

  46. What does NP-complete mean and how is NP-completeness proved?

    A problem is NP-complete if it is in NP and every NP problem reduces to it in polynomial time (NP-hard). It is proved by polynomial-time reduction from a known NP-complete problem (e.g., SAT via Cook-Levin theorem). If any NP-complete problem is in P, then P=NP.

  47. How do you construct a Turing machine for a simple problem like recognizing {a^n b^n c^n | n≥1}?

    Repeatedly scan the tape: mark the leftmost unmarked a (e.g., as X), move right to mark the next b (Y), then the next c (Z), and return left; loop until all are marked. Accept if every a,b,c is matched in correct order with equal counts; reject otherwise. (This language is context-sensitive, not context-free.)

  48. How is the translation of a declaration like 'int x' handled in syntax-directed translation?

    A semantic rule computes the type and width from the type specifier and uses inherited attributes to record each identifier's type, width, and relative storage offset in the symbol table, advancing the offset for the next declaration.

  49. How is an assignment statement translated into three-address code?

    Each sub-expression is evaluated into a temporary; the synthesized attribute holds the place (name/temp) of the result. For x = a+b*c, emit t1 = b*c; t2 = a+t1; x = t2. Array and indexed assignments compute the address offset first.

  50. How are Procedure Calls handled at the code-generation/runtime level?

    The caller evaluates and passes actual parameters (via the param instruction / pushing onto the stack), saves machine state, sets up the activation record, and transfers control (call). On return the callee restores state, passes back any return value, and control resumes after the call site.

UGC NET Computer Science Theory of Computation and Compilers FAQ

What is in the UGC NET Computer Science Theory of Computation and Compilers syllabus?

UGC NET Computer Science Theory of Computation and Compilers is split into 10 chapters: Theory of Computation, Regular Language Models, Context Free Language, Turing Machines (TM), Unsolvable Problems and Computational Complexity, Syntax Analysis, Semantic Analysis, Run Time System, Intermediate Code Generation and Code Generation and Code Optimization. Together they contain 72 topics.

How many chapters are in UGC NET Computer Science Theory of Computation and Compilers?

10 chapters, containing 72 topics. The largest chapter is Regular Language Models, with 10 topics.

Are there flashcards for UGC NET Computer Science Theory of Computation and Compilers?

Yes — a 70-card Theory of Computation and Compilers deck, printed in full in the flashcards section of this page and available in the Examius app with spaced repetition. The free plan covers one exam of your choice, including its flashcards; Examius Pro, a one-time purchase, unlocks every other exam and deck.