Last Minute Notes Theory of Computation (original) (raw)

Last Updated : 3 Jan, 2026

Theory of Computation (TOC) is the part of computer science that studies which problems computers can solve, how they solve them, and how efficiently they can do it. It includes concepts such as Finite Automata, Regular Expressions, Context-Free Grammars, and Turing Machines. These topics help in understanding computational problems and algorithms, and they form the foundation of problem-solving in computer science.

Last Minute Notes - Theory of Computation - GeeksforGeeks

Basics

**1. Symbol and Alphabet

**2. String

**3. Operations on Strings

**4. Prefix, Suffix, and Substring

**5. Language

**Types of Languages

classification_of_languages

**Relation Between Symbol, Alphabet, String, and Language

  1. **Symbol: The smallest unit, e.g., a, b, 0, 1.
  2. **Alphabet (Σ): A finite set of symbols, e.g., Σ = {a, b}.
  3. **String: A sequence of symbols from an alphabet, e.g., abba.
  4. **Language: A set of strings over an alphabet, e.g., L = {ab, aab, abb}.

**Chomsky Hierarchy

chomsky

Chomsky Hierarchy

Read more about Chomsky Hierarchy in TOC.

Finite Automata

Finite Automata (FA) is a simple mathematical model used to represent and recognize regular languages. FA = (Q, Σ, δ, q0 , F)

Finite Automaton can be categorized into two types:

Acceptor (Without Output)

Transducer (With Output)

**Types of FA:

**Deterministic Finite Automata (DFA): Transition function: δ: Q × Σ → Q
(Maps a state and input symbol to a single next state).

**Non-Deterministic Finite Automata (NFA):

Read more about Introduction to FA.

**Note:

**Steps to Construct a DFA:

**Steps to Construct an NFA:

Simple and flexible, NFAs are easier to design than DFAs.

NFA to DFA Conversion

Step 1: Convert the given NFA to its equivalent transition table.
Step 2: Create the DFA’s start state.
Step 3: Create the DFA’s transition table.
Step 4: Create the DFA’s final states.
Step 5: Simplify the DFA.
Step 6: Repeat steps 3-5 until no further simplification is possible.

Read more about NFA to DFA Conversion, Here.

**Minimization of DFA

Suppose there is a DFA D < Q, Δ, q0, Δ, F > which recognizes a language L. Then the minimized DFA D < Q’, Δ, q0, Δ, F’ > can be constructed for language L as:
**Step 1: We will divide Q (set of states) into two sets. One set will contain all final states and other set will contain non-final states. This partition is called P0.
**Step 2: Initialize k = 1
**Step 3: Find Pk by partitioning the different sets of Pk-1. In each set of Pk-1, we will take all possible pair of states. If two states of a set are distinguishable, we will split the sets into different sets in Pk.
**Step 4: Stop when Pk = Pk-1 (No change in partition)
**Step 5: All states of one set are merged into one. No. of states in minimized DFA will be equal to no. of sets in Pk.
**How to find whether two states in partition P k are distinguishable ?
Two states ( qi, qj ) are distinguishable in partition Pk if for any input symbol a, Δ ( qi, a ) and Δ ( qj, a ) are in different sets in partition Pk-1.

Read more about Minimization of DFA.

Moore and Mealy Machine

**Moore Machine:

**Mealy Machine:

**Note: Mealy Machines often require fewer states than Moore Machines for the same functionality.

Read about Mealy and Moore Machine, Here.

Regular Expression

A regular expression represents a regular language and describes a regular set.

**Operators of Regular Expressions

**OR ( | ): Binary Operator, Combines two patterns, Example: a|b{a, b}.

**Concatenation ( . ): Binary Operator, Joins two patterns in sequence, Example: ab{ab}.

**Kleene Star ( * ): Unary Operator, Allows repetition (zero or more times), Example: a*{ε, a, aa, aaa, ...}.

**Kleene Plus ( + ): Unary Operator, Allows repetition (one or more times), Example: a+{a, aa, aaa, ...}.

**Language Over Σ
Languages over an alphabet (Σ) can be classified as:

**Finite Set:

**Infinite Set:

**Identification of Regular Languages

**1. Finite Languages are Always Regular

**2. Infinite Languages are Regular if they Follow Patterns

**3. Closure Properties of Regular Languages

Read about Closure Properties of Regular Languages, Here.

**4. How to Identify Non-Regular Languages

A language is not regular if:

  1. **Memory is required: The language needs to keep track of counts or comparisons.
    Example: L = {a^n b^n | n ≥ 0} → Non-regular, as it requires matching the number of as and bs.
  2. **Nested Patterns: The language contains self-referencing structures like palindromes.
    Example: L = {ww^R | w ∈ Σ*} → Non-regular.

**5. Pumping Lemma Test

Read about Properties of RegEx, Here.

A**rden's Theorem

**Statement:

**Solution:

**Example:
Given R=a+Rb:

Read about Arden's Theorem, Here.

Regular Grammar

**Definition: A regular grammar is a formal grammar that generates regular languages.

**Types of Regular Grammar:

**Properties:

**Example :

**Grammar :

**Language (L): L={aa,bb}

Read about Regular Grammar, Here.

comparison_of_various_langauages

Context Free Grammar

**Definition: A context-free language is generated by a Context-Free Grammar (CFG) where each production rule follows:
V → (V ∪ T)*

**Derivations to Generate Strings:

**Linear Derivation:

**Non-Linear Derivation:

**Types of Context-Free Grammars (CFG)

**Ambiguous Grammar:

**Unambiguous Grammar:

**Left-Recursive Grammar:

**Right-Recursive Grammar:

**Regular Grammar:

Read about Context Free Grammar, Here.

Push Down Automata

A PDA is a computational model that extends a finite automaton by using a stack for additional memory. It recognizes context-free languages (CFLs).

Read about Introduction to Pushdown Automata, Here.

**Types of Pushdown Automata (PDA)

Pushdown Automata (PDA) are used to recognize context-free languages (CFLs), classified into deterministic context-free languages (DCFLs) and general CFLs.

**1. Deterministic Pushdown Automata (DPDA)

**Definition: A DPDA allows at most one transition for each combination of input symbol, current state, and stack symbol.

**Recognizes: Deterministic Context-Free Languages (DCFLs), which are a subset of CFLs.

**Characteristics:

**Usage: Recognizes languages with clear, unambiguous structures.

**2. Non-Deterministic Pushdown Automata (NPDA)

**Definition: An NPDA allows multiple transitions for the same input symbol, current state, and stack symbol.

**Recognizes: All Context-Free Languages (CFLs).

**Characteristics:

**Usage: Recognizes all CFLs, including ambiguous languages.

**Note:

**Key Difference Between DPDA and NPDA

**Feature **DPDA **NPDA
**Language Recognized DCFL (Subset of CFL) CFL (All Context-Free Languages)
**Transitions Single transition per input Multiple transitions allowed
**Ambiguity Cannot handle ambiguous grammars Can handle ambiguous grammars

Read about Difference Between DPDA and NPDA, Here.

**Closure Properties of CFLs and DCFLs

**Operation **CFL **DCFL
Union (L1∪L2) Closed Not Closed
Concatenation (L1⋅L2) Closed Not Closed
Kleene Star (L*) Closed Not Closed
Intersection (L1∩L2) Not Closed Closed with Regular
Complement (Lc) Not Closed Closed
Reversal (LR) Closed Not Closed
Homomorphism Closed Not Closed
Substitution Closed Not Closed
Intersection with Regular Closed Closed
Difference (L1−L2) Not Closed Not Closed

Read about Closure Properties of CFLs, Here.

identification_of_regulars_dcfls_and_cfls

**Key Points:

Turing Machine

**Components:

**Transition Function:

**Types of Turing Machines:

**Language Classification:

**Special Types of TMs:

**Key Properties:

Read more about Turing Machine in TOC, Here.

**Church-Turing Thesis:

Read about Chruch-Turing Thesis, Here.

**Important Points:

**Time Complexity:

Recursive and Recursive Enumerable Language

**Recursive Language (Decidable Language): A language is recursive if there exists a Turing Machine (TM) that halts on every input and correctly decides whether the input is in the language.

**Recognizable or Recursively Enumerable Language (Semi-Decidable Language): A language is recursively enumerable if there exists a Turing Machine (TM) that halts and accepts inputs that belong to the language, but it may loop forever for inputs not in the language.

Read about Recursive and Recursive Enumerable Language in TOC, Here.

**Complement Property of Rec and RE Language:
Complement of Recursive set is Recursive.
Complement of RE is either Recursive or non-RE.
Complement of RE never be “RE which is not recursive”.

**Closure Properties of RE and Rec Language

**Operation **Recursive Languages (Rec) **Recursively Enumerable Languages (RE)
**Union Closed Closed
**Intersection Closed Not Closed
**Complement Closed Not Closed
**Concatenation Closed Closed
**Kleene Star Closed Closed
**Difference Closed Not Closed
**Reversal Closed Closed
**Intersection with Regular Closed Closed

**Decidable Problems (Recursive Languages):

**Undecidable Problems:

Problems for which no Turing Machine (HTM) exists to solve them for all inputs.

Further classified into:

Read about Decidable and Undecidable Problem in TOC, Here.

decidability_table

**Countability in Turing Machines

Read more about Determining Countability in TOC, Here.

See Last Minute Notes on all subjects , here.