TOC DFA Regex NFA Explained
TOC DFA Regex NFA Explained
Automaton.
• It is a theoretical model of
computation used to recognize
Introduction regular languages.
to DFA • Consists of a finite set of states
and transitions.
• For each input symbol, there is
exactly one transition from each
state.
• A DFA is a 5-tuple (Q, Σ, δ, q0, F):
• Q: Finite set of states
Components • Σ: Finite input alphabet
of a DFA • δ: Transition function (Q × Σ → Q)
• q0: Start state (q0 ∈ Q)
• F: Set of accept states (F ⊆ Q)
• Example: DFA that accepts strings
ending with '01' over Σ = {0, 1}
• States: q0 (start), q1, q2 (final)
• Transitions:
• - q0 --0--> q0
DFA Example • - q0 --1--> q1
• - q1 --0--> q2
• - q2 --1--> q1
• Accepts strings like: 1101, 01,
1001
• Regular expressions describe
Introduction regular languages.
• They are symbolic notations used
to Regular to represent patterns in strings.
Expressions • Useful in lexical analysis and
string matching.
• Basic Symbols:
• - a, b: literal characters
• - ε: empty string
Regular • - + : union (e.g., a+b matches 'a'
Expression or 'b')
Symbols • - * : Kleene star (e.g., a* matches
'', 'a', 'aa', etc.)
• - . : concatenation (e.g., ab
matches 'ab')
• Example: (a + b)* abb
Regular • Matches all strings ending with
Expression 'abb' after any combination of 'a'