12 Osama Assignment 1.Docx

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

Name: Osama Naseer

MSCS:2nd semester

Roll no.13

Subject:Theory of Computation (TOC)

Assignment no.1

Q.1)​What do you mean by Automata. Differentiate between DFA and NFA.


Ans:Automata are abstract machines or mathematical models that describe computational
processes. They are used to study the behavior of discrete systems and are fundamental in the
fields of computer science and formal language theory. Automata theory deals with the
definitions and properties of different types of automata.
DFA
The transition from a state is to a single particular next state for each input symbol. Hence it is
called deterministic.

A Deterministic Finite Automaton (DFA) is a specific type of automaton characterized by the


following properties:

1. Determinism: For each state and input symbol, there is exactly one transition to a next
state.
2. Finite States: The automaton consists of a finite number of states.
3. Formal Definition: A DFA can be defined as a 5-tuple (Q,Σ,δ,q0,F)(Q,Σ,δ,q0​,F) where:
○ QQ is a finite set of states.
○ ΣΣ is a finite set of input symbols (alphabet).
○ δδ is the transition function, δ:Q×Σ→Qδ:Q×Σ→Q, mapping a state and input
symbol to the next state.
○ q0q0​is the start state, where q0∈Qq0​∈Q.
○ FF is the set of accept states, F⊆QF⊆Q.

NFA
A Nondeterministic Finite Automaton (NFA) is a type of finite automaton that allows multiple
transitions for a given state and input symbol, including transitions that do not consume any
input symbols (ε-transitions).NFA also has five states as DFA but with differ transitions
functions:
○ QQ is a finite set of states.
○ ΣΣ is a finite set of input symbols (alphabet).
○ δδ is the transition function, δ:Q×Σ→Qδ:Q×Σ→Q, mapping a state and input
symbol to the next state.
○ q0q0​is the start state, where q0∈Qq0​∈Q.
○ FF is the set of accept states, F⊆QF⊆Q.

Differences between DFA and NFA

DFA (Deterministic Finite Automaton)

● Deterministic: Each state has exactly one transition for each input symbol.
● No ε-transitions: Transitions are only based on input symbols, not empty moves.
● Simplicity: Easier to implement and understand due to its deterministic nature.

NFA (Nondeterministic Finite Automaton)

● Nondeterministic: A state can have zero, one, or multiple transitions for each input
symbol.
● ε-transitions: Can include transitions that do not consume any input symbols
(ε-transitions).
● Flexibility: Can be more compact and easier to construct for certain languages, but
requires more complex implementation to simulate deterministically.

Q.2)​What are Melay Machine and Moore Machine? Give at least one example for
each.
Ans:Mealy Machine:

● A Mealy machine is a type of finite state machine (FSM) where the outputs are
dependent on both the current state and the inputs.
● In a Mealy machine, outputs are produced upon transitions between states and the

input that triggers the transition.

Moore Machine:

● A Moore machine is another type of finite state machine where the outputs are dependent
only on the current state.
● In a Moore machine, outputs are associated with each state and do not directly depend on
the inputs that caused the state transition.

You might also like