0% found this document useful (0 votes)
21 views8 pages

Deepa Mam

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

Deepa Mam

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

Assignment -1

Q1. Define DFA n NFA


DFA (Deterministic Finite Automaton): A DFA is a mathematical
model used to recognize or accept a regular language. It consists of a
finite set of states, a finite alphabet of input symbols, a transition
function that maps a state and an input symbol to a new state, a start
state, and a set of accepting states. The DFA reads input symbols one
at a time and transitions from one state to another based on the
current state and the input symbol.

NFA (Nondeterministic Finite Automaton): An NFA is another


mathematical model used to recognize or accept a regular language.
It is similar to a DFA but allows for nondeterminism, meaning that
from a given state and input symbol, there can be multiple possible
transitions. It consists of a finite set of states, a finite alphabet of
input symbols, a transition function that maps a state and an input
symbol to a set of states, a start state, and a set of accepting states.

Q2.Make a D F A which can accept the string


ab.
Here is a DFA that accepts the string "ab":
- States: {q0, q1, q2}
- Alphabet: {a, b}
- Start state: q0
- Accepting state: q2
- Transition function:
- δ(q0, a) = q1
- δ(q1, b) = q2
Assignment -1
- For all other combinations of states and input symbols, the DFA
goes into a trap state (not shown in the diagram).

```
a b
→(q0) ──▶ (q1) ──▶ (q2) (Accepting state)
```

Q3.Define regular expression n regular string

Regular Expression: A regular expression is a sequence of characters


that defines a search pattern. It is used to match strings in a text
according to a specified pattern. Regular expressions can be used to
describe regular languages.

Regular String: A regular string is a string that matches a given regular


expression. It satisfies the pattern defined by the regular expression.

Q4.Make a DFA which aacept all the string


generated with a n b but start with ba.
.

4. Here is a DFA that accepts all strings generated with "a" and "b"
but start with "ba":
- States: {q0, q1, q2}
Assignment -1
- Alphabet: {a, b}
- Start state: q0
- Accepting state: q1
- Transition function:
- δ(q0, b) = q1
- δ(q1, a) = q2
- δ(q1, b) = q1
- δ(q2, a) = q2
- δ(q2, b) = q2

```
a b
→(q0) ──▶ (q1) ──▶ (q2) (Accepting state)
```

Q5. Make a DFA which accept all the string


end with ba but generated with a and b
Here is a DFA that accepts all strings generated with "a" and "b" but
end with "ba":
- States: {q0, q1, q2}
- Alphabet: {a, b}
- Start state: q0
- Accepting state: q2
- Transition function:
Assignment -1
- δ(q0, a) = q0
- δ(q0, b) = q1
- δ(q1, a) = q0
- δ(q1, b) = q1
- δ(q2, a) = q0
- δ(q2, b) = q1

```
a b
→(q0) ──▶ (q1) ──▶ (q2) (Accepting state)
```

Q6. What is regular expression of q4 n q


5.also express regular string

Regular expression of q4: The regular expression for the DFA in question 4
is "ba(a+b)*".

Regular expression of q5: The regular expression for the DFA in


question 5 is "(a+b)*ba".

Regular string: A regular string is a string that matches a regular


language or can be described by a regular expression. For q4, a
regular string could be "baabababa", and for q5, a regular string
could be "abababa".
Assignment -1

Q7. Make a DFA of ab(a+b)*a

DFA of ab(a+b)*a:
- States: {q0, q1, q2}
- Alphabet: {a, b}
- Start state: q0
- Accepting state: q2
- Transition function:
- δ(q0, a) = q1
- δ(q1, b) = q2
- δ(q2, a) = q2
- δ(q2, b) = q2

```
a b
→(q0) ──▶ (q1) ──▶ (q2) (Accepting state)
```

Q8. Define push down automata. what is it's


benefit
Pushdown Automaton (PDA): A pushdown automaton is an
extension of a finite automaton with an additional stack. It can
recognize context-free languages, which are more powerful than
regular languages. The stack allows thePDA to keep track of and
manipulate additional information while processing input symbols.
Assignment -1
The PDA consists of a finite set of states, a finite alphabet of input
symbols, a finite stack alphabet, a transition function that maps a
state, an input symbol, and the top symbol of the stack to a new state
and a stack operation, a start state, and a set of accepting states.

The benefit of a pushdown automaton is that it can recognize a larger


class of languages compared to a finite automaton. It can handle
context-free languages, which include many practical programming
language constructs and grammars. PDAs are used in various
applications, such as parsing and syntax analysis in compilers, pattern
matching, and natural language processing.

Q9.Make a push down automata of string of


string a^nb^n
Here is a PDA that accepts the language of strings consisting of 'a's
followed by an equal number of 'b's: a^n b^n, where n >= 0.
- States: {q0, q1, q2}
- Alphabet: {a, b}
- Stack Alphabet: {Z0, A} (Z0 is the initial stack symbol)
- Start state: q0
- Accepting state: q2
- Transition function:
- δ(q0, a, Z0) = (q0, AZ0)
- δ(q0, a, A) = (q0, AA)
- δ(q0, b, A) = (q1, ε)
- δ(q1, b, A) = (q1, ε)
Assignment -1
- δ(q1, ε, Z0) = (q2, Z0)

Note: ε represents an empty string, and (state, symbol) = (new state,


stack operation).
This PDA pushes an 'A' onto the stack for each 'a' it reads. When it
encounters a 'b', it pops an 'A' from the stack. If the input string
consists of 'a's followed by an equal number of 'b's, the PDA will
reach the accepting state q2.

Q10. make a pushdowm automata of


reversible string generated with a,b
Here is a PDA that accepts the language of reversible strings
generated with 'a' and 'b':
- States: {q0, q1, q2}
- Alphabet: {a, b}
- Stack Alphabet: {Z0, A} (Z0 is the initial stack symbol)
- Start state: q0
- Accepting state: q0
- Transition function:
- δ(q0, a, Z0) = (q0, AZ0)
- δ(q0, a, A) = (q0, AA)
- δ(q0, b, A) = (q1, ε)
- δ(q1, b, A) = (q1, ε)
- δ(q1, a, A) = (q2, ε)
- δ(q2, a, A) = (q2, ε)
Assignment -1
- δ(q2, ε, Z0) = (q0, Z0)

This PDA pushes an 'A' onto the stack for each 'a' it reads. When it
encounters a 'b', it pops an 'A' from the stack. If the input string is
reversible (can be read the same forwards and backwards), the PDA
will continuously loop between states q0 and q2, ultimately reaching
the accepting state q0.

You might also like