0% found this document useful (0 votes)
3 views

TOC IA 1 - QB Answers

Uploaded by

0702priyarmane
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

TOC IA 1 - QB Answers

Uploaded by

0702priyarmane
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

TOC (BCS503)

IA 1 - QB Answers

1. Define the following terms with example.

(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.

(b) Alphabet (Σ)

 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, …}.

(d) Deterministic Finite Automata (DFA)

 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".

(d) Deterministic Finite Automata (DFA)

 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".

(e) Nondeterministic Finite Automata (NFA)

 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".

(f) Ɛ-NFA (Epsilon-NFA)

 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}.

(h) Powers of an Alphabet


(i) Language of DFA

 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.

(j) Language of NFA

 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.

2. Explain the differences between DFA and NFA.

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,…}

For where δ={ δ(qo,0)=q2, δ(qo,1)=q0, δ(q1,0)=q1, δ(q1,1)=q1, δ(q2,0)=q2, δ(q2,1)=q1 }

a) L = {w ∈ {a, b}* : every a in w is immediately preceded and followed by b}.


b) L = {w ∈ {a, b}* : w does not end in ba }.

c) L = {w ∈ {a, b}* : w has bbab as a substring}.

d) L = {w ∈ {a, b}* : w has neither ab nor bb as a substring}.

e) L = {w ∈ {0, 1}* : w is of even length and begins with 01}.


f) L = {w ∈ {0, 1}* : strings such that number of 1's is even and the number of 0's is a multiple of 3 }

g) L = {w ∈ {0, 1}* : w corresponds to the binary encoding, without leading 0’s, of natural numbers that are evenly
divisible by 3}.

h) L = {w ∈ {0, 1}* : w has 001 as a substring}

i) L = {w ∈ {0, 1}* : w does not have 001 as a substring}.

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

pairof consecutive 1’s.

l) L = {w ∈ {a, b}* : |w| mod 5= 0 }

m) L = {w ∈ {a, b}* : In w, 4

th character from last is a }

n) L = {w ∈ {a, b}* : w is not ending with abb }.

o) L = {w ∈ {a, b}* : all strings with at least one 'a' and exactly two 'b's}

p) L = { w ∈ {a-z}* : all five vowels occur in w in alphabetical order }

q) L = {w ∈ {a, b}* : w has both aa and bb as a substrings}.


5. Convert following NFA to DFA using subset construction method

a)

You might also like