Beruflich Dokumente
Kultur Dokumente
first one is alphabet and second one is the set of all string of length 1.
*The set of all strings over an alphabet is conventionally denoted by
* 0 1 2 .........
*Sometimes, we wish to exclude the empty string from the set of all
LUCKNOW
0522-6563566
LUCK NOW
GORAKHPUR
9919526958
ALLAHABAD
AGRA
9919751941
9451056682
PATNA
9919751941
NOIDA
SUMMER CRASH COURSE ONLINE TEST SERIES
9919751941 WINTER CRASH COURSE OFF-LINE TEST SERIES
TECHGURU CLASSES for ENGINEERS (Your Dedication + Our Guidance = Sure Success)
1 2 3 ......... or
*
Operation on Strings:
Concatenation: Let x and y be two strings in * . Let us form a
new string z by placing y after x, i.e.frorm z = xy. The string z is said to
be obtained by concatenation of x and y.
,
* , then x yz = xy z
* has left and right cancellation property. For x, y, z in * .
zx = zy implies x = y (left cancellation)
xz = yz implies x = y (right cancellation)
For xy in * , we have
LUCK NOW
GORAKHPUR
9919526958
ALLAHABAD
AGRA
9919751941
9451056682
PATNA
9919751941
NOIDA
SUMMER CRASH COURSE ONLINE TEST SERIES
9919751941 WINTER CRASH COURSE OFF-LINE TEST SERIES
TECHGURU CLASSES for ENGINEERS (Your Dedication + Our Guidance = Sure Success)
PERSONAL REMARK :
10,11,101,111,1011,......
*
Example 3: is a language over any alphabet .
,
*
respect to ; that is the complement of L is: L * L
,
LR R ; L
The concatenation of languages L1 and L2 are obtained by concatenating
any element of L1 with any element of L2 , i.e.
L1L 2 12 : 1 L1 and 2 L 2
cases
L0
Finite Automata
Automata: An automata is an abstract model of a digital computer.
Every automata includes some essential features. It has a mechanism
for reading input. It is assumed that the input is a string over a given
alphabet, written on an input file, which the automaton can read but not
change. The input file is divided into cells, which the automaton can read
but not change. The input file is divided into cells, each of which holds
one symbol. The input mechanism can read the input file left to right, one
symbol at a time. The input mechanism can also detect the end of the
input string (by sensing the end-of-file condition). The automaton can
produce output of some form. It may have a temporary storage device,
consisting of an unlimited number of cells, each capable of holding a
single symbol from an alphabet (not necessarily the same one as the
input alphabet). The automaton can read and change the contents of the
storage cells. Finally the automaton has control unit which can be in any
of the finite number of internal states, and which can change its state in
some specified.
LUCKNOW
0522-6563566
LUCK NOW
GORAKHPUR
9919526958
ALLAHABAD
AGRA
9919751941
9451056682
PATNA
9919751941
NOIDA
SUMMER CRASH COURSE ONLINE TEST SERIES
9919751941 WINTER CRASH COURSE OFF-LINE TEST SERIES
TECHGURU CLASSES for ENGINEERS (Your Dedication + Our Guidance = Sure Success)
Input file
Storage
Control Unit
The term deterministic refer to the fact that on each input symbol
there is one and only one state to which the automaton can transition
from its current state.
,
LUCK NOW
GORAKHPUR
9919526958
ALLAHABAD
AGRA
9919751941
9451056682
PATNA
9919751941
NOIDA
SUMMER CRASH COURSE ONLINE TEST SERIES
9919751941 WINTER CRASH COURSE OFF-LINE TEST SERIES
TECHGURU CLASSES for ENGINEERS (Your Dedication + Our Guidance = Sure Success)
edge indicate the transition of a state and the edges are labeled with
input/output symbols. For every transition rule (q,i a) qj the graph has
an edge q i , q j labeled a di rected from q i to q j and the edge labeled
with a.
In the transition diagram there is an arrow at start vertex q0. This arrow
does not originate at any node.
In transition diagram the nodes corresponding to the final state are marked
by a double circle. States not in F have a single circle.
,
0,1
0
0
PERSONAL REMARK :
q1
q2
Where is given by
(q 0 , 0) q1 , (q1 ,0) q1 (q 2 ,0) q 2
(q 0 ,1) q 0 , (q1 ,1) q 2 (q 2 ,1) q 2
2. Transition Table: A transition table is a conventional, tabular
representation of a function that takes two arguments and returns a value.
The row of the table correspond to the states and the columns, correspond
to the inputs. The transition table of the corresponding transition graph of
the above is given below.
States/
q0
q1
q0
q1
q1
q2
q2
q2
q2
LUCK NOW
GORAKHPUR
9919526958
ALLAHABAD
AGRA
9919751941
9451056682
PATNA
9919751941
NOIDA
SUMMER CRASH COURSE ONLINE TEST SERIES
9919751941 WINTER CRASH COURSE OFF-LINE TEST SERIES
TECHGURU CLASSES for ENGINEERS (Your Dedication + Our Guidance = Sure Success)
PERSONAL REMARK :
Property 1:
q, q in a finite automation. This means the state
of the system can be change only by an input symbol.
For all string and input symbols a
Property 2:
q, a q , a ,
q, a q, , a
This property gives the state after the automaton consumes or reads the
first symbol of a string a and the state after the automaton consumes
a prefix of the string a .
notation,
L M * ; q 0 F
Example 1:
a,b
q1
b
,
a,b
q2
The automaton in the above figure remains in state q 0 (initial state) until
the first b is encountered. If this is the last symbol of the input, then the
string is accepted. If not, the DFA goes into state q 2 , from which it cantt
escape. Such a state is called trap state. Thus the automaton accepts all
string consisting of an arbitrary number of as followed by a single b. all
other strings are rejected.
Problem: Find a deterministic finite accepter that recognize the set of
all strings on a , b starting with the prefix a b.
Solution: If the first symbol is an a and the second is a b, the automation
goes into a final state, where it will stay since the rest of the input does
not matter on the other hand, if the first symbol is not an a or the second
input is not a b the automaton enters the non-final trap state.
a,b
a
b
q2
q1
a
q2
a,b
Regular language:
A language L is called regular if and only if there exists some deterministic
LUCKNOW
0522-6563566
LUCK NOW
GORAKHPUR
9919526958
ALLAHABAD
AGRA
9919751941
9451056682
PATNA
9919751941
NOIDA
SUMMER CRASH COURSE ONLINE TEST SERIES
9919751941 WINTER CRASH COURSE OFF-LINE TEST SERIES
TECHGURU CLASSES for ENGINEERS (Your Dedication + Our Guidance = Sure Success)
PERSONAL REMARK :
a
b
a,b
,
The DFA in the figure shown on the left accept the language
L a a : t a , b* So, L is regular..
Problem: For a , b , construct DFAs that accept the sets of
(a) all strings with exactly one a
(b) all strings with atleast one a.
(c) all string no more than three as
(d) all string with at least one a and exactly two bs.
Solution:
b
(a)
,
a,b
a
q1
q2
Where is given by
q 0 , a q1 , q 0 , b q 0 , q1 , a q 2
q1 , b q1 , q 2 , a q 2 , q 2 , b q 2
a,b
(b)
,
q2
b
(c)
LUCKNOW
0522-6563566
LUCK NOW
q0
b
a
GORAKHPUR
9919526958
q1
q2
b
a
ALLAHABAD
AGRA
9919751941
9451056682
a,b
a
PATNA
9919751941
NOIDA
SUMMER CRASH COURSE ONLINE TEST SERIES
9919751941 WINTER CRASH COURSE OFF-LINE TEST SERIES
TECHGURU CLASSES for ENGINEERS (Your Dedication + Our Guidance = Sure Success)
PERSONAL REMARK :
a
q5
q0
a,b
q1
q6
a
b
q2
qEE
qE0
1
0
0
q0E
0
1
0
q00
1
Problem: Construct a DFA for the language L a n : a 4
Solution:
LUCK NOW
GORAKHPUR
9919526958
ALLAHABAD
AGRA
9919751941
9451056682
PATNA
9919751941
NOIDA
SUMMER CRASH COURSE ONLINE TEST SERIES
9919751941 WINTER CRASH COURSE OFF-LINE TEST SERIES
TECHGURU CLASSES for ENGINEERS (Your Dedication + Our Guidance = Sure Success)
PERSONAL REMARK :
b
q2
q1
q2
LUCKNOW
0522-6563566
LUCK NOW
GORAKHPUR
9919526958
ALLAHABAD
AGRA
9919751941
9451056682
PATNA
9919751941
NOIDA
SUMMER CRASH COURSE ONLINE TEST SERIES
9919751941 WINTER CRASH COURSE OFF-LINE TEST SERIES
TECHGURU CLASSES for ENGINEERS (Your Dedication + Our Guidance = Sure Success)
Problem: Construct a DFA that will accept all those binary strings
whose decimal equivalent is divisible by 5.
Solution: We know that (from mathematics of mod operation)
If x mod n = p, then
2x mod n = 2p mod n
and 2x + 1 mod n 2p 1 mod n.
,
Now assume that the partial string read by the DFA has decimal equivalent
x. If next bit 0, the string read
so far will have a decimal equivalent 2x and it 2x 1 if the next bit is 1.
x mod 5 could be any values between 0 and 4. so we need 5 states to
remember these values. Let q0, q1, q2, q3 and q4 denotes the states
corresponding to remainders 0, 1, 2, 3 and 4 respectively. Draw the
transition table first.
1
0
q0
q2
q1
q4
q3
LUCKNOW
0522-6563566
LUCK NOW
States
q0
q0
q1
q1
q2
q3
q2
q4
q0
q3
q1
q2
q4
q3
q4
GORAKHPUR
9919526958
ALLAHABAD
AGRA
9919751941
9451056682
PATNA
9919751941
NOIDA
SUMMER CRASH COURSE ONLINE TEST SERIES
9919751941 WINTER CRASH COURSE OFF-LINE TEST SERIES
10
TECHGURU CLASSES for ENGINEERS (Your Dedication + Our Guidance = Sure Success)
PERSONAL REMARK :
1
0
q1
1
1
q2
Definition (NFA):
,
LUCKNOW
0522-6563566
LUCK NOW
GORAKHPUR
9919526958
ALLAHABAD
AGRA
9919751941
9451056682
PATNA
9919751941
NOIDA
SUMMER CRASH COURSE ONLINE TEST SERIES
9919751941 WINTER CRASH COURSE OFF-LINE TEST SERIES
11
TECHGURU CLASSES for ENGINEERS (Your Dedication + Our Guidance = Sure Success)
q1
,
q2
Then from the union of all these N , yielding the set q , q m , .........., q n
i.e
q , q m , ....., q n N q i , a N q j , a N q k , a
LUCK NOW
GORAKHPUR
9919526958
ALLAHABAD
AGRA
9919751941
9451056682
PATNA
9919751941
NOIDA
SUMMER CRASH COURSE ONLINE TEST SERIES
9919751941 WINTER CRASH COURSE OFF-LINE TEST SERIES
12
TECHGURU CLASSES for ENGINEERS (Your Dedication + Our Guidance = Sure Success)
PERSONAL REMARK :
1
q1
0,1
q2
0,1
States/
q0
q0 , q1
q1
q2
q2
q1
q2
,
q2
States/
q0, q1
q1
q0, q1
q0, q1, q2
q1, q2
q0, q1, q2
q0, q1, q2
q1, q2
q1, q2
q2
q2
q1
q2
q2
q2
q2
q0
1
0
q1
q0,q1
0,1
1
q1,q2
q2
q0,q1,q2
0,1
Example:
Find
0,1
deterministic
accepter
equivalent
to
LUCKNOW
0522-6563566
LUCK NOW
GORAKHPUR
9919526958
ALLAHABAD
AGRA
9919751941
9451056682
PATNA
9919751941
NOIDA
SUMMER CRASH COURSE ONLINE TEST SERIES
9919751941 WINTER CRASH COURSE OFF-LINE TEST SERIES
13
TECHGURU CLASSES for ENGINEERS (Your Dedication + Our Guidance = Sure Success)
States/
q0
q0 , q1
q2
q0
q1
q1
q2
q 0 , q1
States/
q0
q0, q1
q2
q0, q1
q0, q1
q1, q2
q2
q0, q1
q1, q2
q0
q0, q1
b
q0,q1
q2
q1,q2
0,1
0
States/
q1
q1
q0 , q1
q2
q1
q2
q2
q0
LUCK NOW
States/
GORAKHPUR
9919526958
q0
q0 , q1
q0
ALLAHABAD
AGRA
9919751941
9451056682
PATNA
9919751941
NOIDA
SUMMER CRASH COURSE ONLINE TEST SERIES
9919751941 WINTER CRASH COURSE OFF-LINE TEST SERIES
14
TECHGURU CLASSES for ENGINEERS (Your Dedication + Our Guidance = Sure Success)
PERSONAL REMARK :
1
0
q0,q1
q0,q2
1
Problem: Construct a NFA accepting ab, ba and use it find a DFA
accepting the same string over a , b.
Solution: The transition table and transition diagram of the NFA is given
below.
q1
q2
b
q3
States/
q0
q1
q3
q1
q2
q2
q3
q2
States/
b1
q0
q1
q3
q1
q2
q2
q3
q2
Problem: Draw the transition diagram of DFA for the following language.
On a , b.
L : mod 3 0
Solution:
LUCKNOW
0522-6563566
LUCK NOW
GORAKHPUR
9919526958
ALLAHABAD
AGRA
9919751941
9451056682
PATNA
9919751941
NOIDA
SUMMER CRASH COURSE ONLINE TEST SERIES
9919751941 WINTER CRASH COURSE OFF-LINE TEST SERIES
15
TECHGURU CLASSES for ENGINEERS (Your Dedication + Our Guidance = Sure Success)
q3
q2
q1
q2
q4
q3
(ii)
b
b
q1
q2
LUCK NOW
GORAKHPUR
9919526958
ALLAHABAD
AGRA
9919751941
9451056682
PATNA
9919751941
NOIDA
SUMMER CRASH COURSE ONLINE TEST SERIES
9919751941 WINTER CRASH COURSE OFF-LINE TEST SERIES
16
TECHGURU CLASSES for ENGINEERS (Your Dedication + Our Guidance = Sure Success)
PERSONAL REMARK :
q2
q1
We say that an NFA accepts a string if there is some path labeled from
the initial state to a final state. Of course, edge labeled may be included
in the path, although the s do not appear explicitly in . For example
the word 002 is accepted by NFA above figure, by the path q0, q0, q0, q1,
q2, q2, with arcs labeled 0, 0, , , 2.
Formally we define a non-deterministic finite automation with moves
to be a five tuple Q, , , q 0 , F with all components as before, but , the
q0
q0
q1
q1
q1
q2
q2
q2
States
- Closure: it denotes the set of all vertices p such that there is a path
from q to p labeled . In the above figure - closure q0= q0, q1, q2. That
is the path consisting of q0 alone (there is no arcs on the path), is a path
from q0 to q0 with all arcs labeled with , path q0, q1 shows that q1 is in
- closure 0 q and path 0 1 2 q ,q ,q shows that 2 q is in -closure q0.
- closure (p), where p is a set of states, be
- closure.
q in p
LUCK NOW
GORAKHPUR
9919526958
ALLAHABAD
AGRA
9919751941
9451056682
PATNA
9919751941
NOIDA
SUMMER CRASH COURSE ONLINE TEST SERIES
9919751941 WINTER CRASH COURSE OFF-LINE TEST SERIES
17
TECHGURU CLASSES for ENGINEERS (Your Dedication + Our Guidance = Sure Success)
PERSONAL REMARK :
q1
q2
q 0 , closure q 0 q 0 , q1, q 2 ,
Thus,
q 0 , 0 closure q 0 ,, 0
closure q 0 , q1 , q 2 , 0
closure q 0 , 0 q1 , 0 q 2 , 0
closure q 0
closure q 0 q 0 , q1 , q 2
Then,
q 0 , 01 closure q 0 , 0, 1
closure q 0 , q1 , q 2 , 1
closure q1 q1 , q 2
LUCKNOW
0522-6563566
LUCK NOW
GORAKHPUR
9919526958
ALLAHABAD
AGRA
9919751941
9451056682
PATNA
9919751941
NOIDA
SUMMER CRASH COURSE ONLINE TEST SERIES
9919751941 WINTER CRASH COURSE OFF-LINE TEST SERIES
18