TOC IA 1 - QB Answers
TOC IA 1 - QB Answers
IA 1 - QB Answers
(a) String
Definition: A string (or word) is a finite sequence of symbols chosen from a specific alphabet.
Example: If we have the binary alphabet Σ = {0, 1}, a valid string could be 01101. Here, each
symbol (0 or 1) is chosen from Σ and combined in sequence to form the string.
Definition: An alphabet is a finite, non-empty set of symbols from which strings are formed. It's
usually denoted by the symbol Σ.
Example:
o Binary alphabet: Σ = {0, 1}.
o Lower-case alphabet: Σ = {a, b, …, z}.
o Custom example: Σ = {x, y, z}.
(c) Language
Definition: A language is a set of strings formed using symbols from a given alphabet (Σ). It
includes various sequences of symbols that adhere to specific patterns or rules.
Examples:
1. Language of equal numbers of 0’s and 1’s: {ε, 01, 10, 0011, 0101, 1001, …}.
2. Binary language with n 0’s followed by n 1’s: {ε, 01, 0011, 000111, …}.
3. Language of binary prime numbers: {10, 11, 101, 111, 1011, …}.
Definition: A DFA is a finite-state machine where each input symbol leads to exactly one state
transition. The term "deterministic" indicates no ambiguity in state transitions.
Structure of DFA: Represented by a 5-tuple (Q, Σ, δ, q0, F), where:
o Q: Finite set of states.
o Σ: Finite input alphabet.
o δ (transition function): Maps a state and input symbol to a single state (δ: Q × Σ → Q).
o q0: Start state.
o F: Set of accepting (final) states.
Example: A DFA that accepts binary strings ending in "01" will only transition to an accepting
state if the last two characters are "01".
Definition: A DFA is a finite-state machine where each input symbol leads to exactly one state
transition. The term "deterministic" indicates no ambiguity in state transitions.
Structure of DFA: Represented by a 5-tuple (Q, Σ, δ, q0, F), where:
o Q: Finite set of states.
o Σ: Finite input alphabet.
o δ (transition function): Maps a state and input symbol to a single state (δ: Q × Σ → Q).
o q0: Start state.
o F: Set of accepting (final) states.
Example: A DFA that accepts binary strings ending in "01" will only transition to an accepting
state if the last two characters are "01".
Definition: An NFA is a finite-state machine where multiple transitions can exist for a single input
symbol from a given state. An NFA can be in multiple states simultaneously.
Structure of NFA: Also represented by a 5-tuple (Q, Σ, δ, q0, F), but δ can map to zero, one, or
more states for each input.
Example: An NFA that accepts strings ending in "01" could explore multiple state paths to reach an
accepting state if the input string ends in "01".
Definition: An Ɛ-NFA is a nondeterministic finite automaton that includes epsilon (Ɛ) transitions,
allowing the automaton to transition between states without consuming any input symbols.
Structure: Represented by a 5-tuple (Q, Σ, δ, q0, F), where:
o Q: Finite set of states.
o Σ: Input alphabet.
o δ: Transition function, mapping states and inputs (including Ɛ) to subsets of states, δ: Q × {Σ
∪ Ɛ} → 2^Q.
o q0: Start state.
o F: Set of accepting states.
Example: In an Ɛ-NFA, the automaton could move from state q to state r just with an Ɛ transition,
without needing any actual input symbol.
(g) Ɛ-Closure
Definition: The Ɛ-closure of a state in an NFA is the set of all states that can be reached from the
given state using only Ɛ transitions.
Properties:
1. Every state in the set (S) is included in its own Ɛ-closure.
2. Any state reachable by Ɛ transitions from any state in S is included in Ɛ(S).
3. No other states are included in Ɛ(S) beyond those reachable by Ɛ.
Example:
o If state q can reach state s via an Ɛ transition, then Ɛ-closure(q) = {q, s}.
Definition: The language of a Deterministic Finite Automaton (DFA) is the set of all strings it
accepts. This includes only those strings for which the DFA reaches an accepting (final) state.
Definition: The language of a Nondeterministic Finite Automaton (NFA) is the set of all strings for
which the NFA can reach an accepting state. Unlike a DFA, an NFA may have multiple paths and
can use epsilon transitions.
Ans:
3. Prove that,
Ans:
4. Build a DFA for each of the following languages.
*For each solution also write: Language Input Accepted i.e L= {ab, aba, abb,…..} Also write Not Accepted L`={ɛ, a,
b,…}
g) L = {w ∈ {0, 1}* : w corresponds to the binary encoding, without leading 0’s, of natural numbers that are evenly
divisible by 3}.
j) L = {w ∈ {a, b}* : w contains at least two b’s that are not immediately followed by a’s}.
k) The set of binary strings with at most one pair of consecutive 0’s and at most one
m) L = {w ∈ {a, b}* : In w, 4
o) L = {w ∈ {a, b}* : all strings with at least one 'a' and exactly two 'b's}
a)