Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
9 views6 pages

Automata

Uploaded by

iphoneindiatoday
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)
9 views6 pages

Automata

Uploaded by

iphoneindiatoday
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/ 6

SUBJECT : AUTOMATA

SUBJECT CODE : PCCCS403


NAME : SUJAY DEY
DEPARTMENT : CSE IOT
ROLL NO : 13031423060
REGISTRATION NO : 231300110078
SEMESTER : 4TH
1. Design a DFA which accepts strings starting with a and ending with b where the
alphabet set is {a,b}.
Design Outline:

1. Initial Check:

o Start at an initial state (q₀).

o If the first symbol is a, move to a state (let’s call it q₁) that signifies the string
has started correctly.

o If the first symbol is b, go to a “dead” state (q_dead) from which acceptance is


impossible.

2. Tracking the Last Symbol:

o From state q₁, whenever you see an a, you remain in q₁ (because the last read
symbol is still a).

o When you see a b, transition to another state (q₂) indicating the last symbol
read is b.

o From q₂, if an a appears later, move back to q₁ (as the new last symbol
becomes a), and if b appears, stay in q₂.

3. Acceptance:

o Only state q₂ (where the most recent symbol is b) is accepting, but note that
the machine must have started in q₁ (i.e., it must have begun with a).

Formal Description:

• States: {q₀, q_dead, q₁, q₂}

• Alphabet: {a, b}

• Transitions:

o From q₀:

▪ On a → q₁

▪ On b → q_dead

o From q_dead (sink state):

▪ On a or b → q_dead

o From q₁:

▪ On a → q₁
▪ On b → q₂

o From q₂ (accepting state):

▪ On a → q₁

▪ On b → q₂

• Start State: q₀

• Accepting State: q₂

This DFA ensures that only strings that start with a and, when finished, end with b will be
accepted.

2. Write a regular expression in alphabet {a,b} for the following: a) Strings which
have the substring aabb. b) Strings whose length is a multiple of 5.

a) Strings with the Substring aabb

Explanation:
For any string to have "aabb" as a substring, it can have any sequence of characters
(including the empty string) before and after the substring "aabb".

Regular Expression: (a|b)* aabb (a|b)*

This expression says: any string made up of a’s and b’s, followed by "aabb", followed by
any string of a’s and b’s.

b) Strings Whose Length is a Multiple of 5

Explanation:
A string’s length is a multiple of 5 if it can be divided into blocks of 5 symbols. Each block
can be any combination of a or b.

Regular Expression: ((a|b)(a|b)(a|b)(a|b)(a|b))*

This indicates zero or more occurrences of any five-character block, ensuring the total
length is 0, 5, 10, 15, … and so on.

3. Write a short note on NFA.


An NFA is a type of finite automaton where:

• Multiple Choices: From a given state and input symbol, the automaton may move to
one, several, or even no states at all.
• ε-Transitions: NFAs can include transitions that do not consume any input symbol
(called epsilon transitions), allowing the automaton to change states
“spontaneously.”

• Equivalence to DFA: Even though an NFA may seem more “flexible” due to non-
determinism, every NFA has an equivalent DFA (deterministic finite automaton) that
recognizes the same language, though the DFA might have many more states.

• Ease of Construction: NFAs are often easier to construct for certain patterns or
languages because you can “guess” the correct path through non-determinism rather
than having to explicitly define every transition.

NFAs are widely used in theoretical computer science and practical applications like pattern
matching and regular expression engines.

4. Explain the concept of equivalent states of a DFA. Is it desirable to have more or


less equivalent states in the automaton? Why?
Concept:

• Equivalent States: Two states in a DFA are equivalent if, for every possible input
string, starting from either state results in the same acceptance or rejection
outcome. In other words, these states are indistinguishable in terms of the language
recognized by the automaton.

Desirability:

• Fewer Equivalent States Preferred:

o Having fewer equivalent states is desirable because if two states are


equivalent, they can be merged without changing the language accepted by
the DFA.

o Merging equivalent states results in a minimized DFA, which is simpler, more


efficient, and easier to analyze.

o A minimized DFA uses the least amount of memory and has simpler transition
diagrams, making it more optimal for both theoretical analysis and practical
implementation.

Thus, in practice, we aim to reduce the number of equivalent states to simplify the
automaton.

5. Design a DFA or NFA which accepts strings with 3k number of a’s where k is a
whole number, and the alphabet set is {a,b}.
We want to design an automaton that accepts strings over {a, b} where the number
of a’s is a multiple of 3 (that is, 0, 3, 6, 9, …).

DFA Design:

1. States Definition:

o Use three states representing the remainder when the count of a’s is
divided by 3:

▪ q₀: 0 mod 3 (also the accepting state since 0 is a multiple of 3)

▪ q₁: 1 mod 3

▪ q₂: 2 mod 3

2. Transition Rules:

o On input a:

▪ From q₀ → go to q₁ (since 0 + 1 ≡ 1 mod 3)

▪ From q₁ → go to q₂ (since 1 + 1 ≡ 2 mod 3)

▪ From q₂ → go to q₀ (since 2 + 1 ≡ 0 mod 3)

o On input b:

▪ b does not affect the count of a’s, so stay in the current state
regardless of which state you are in.

3. Formal Description:

o States: {q₀, q₁, q₂}

o Alphabet: {a, b}

o Start State: q₀

o Accepting State: q₀ (because a count of 0, 3, 6, … is acceptable)

o Transitions:

▪ q₀: on a → q₁; on b → q₀

▪ q₁: on a → q₂; on b → q₁

▪ q₂: on a → q₀; on b → q₂

This DFA correctly accepts strings in which the total number of a’s is a multiple of 3.

You might also like