Mini
Mini
Mini
1. Write the regular expression for variable names. Assume that the variable name can
start with alphabets or underscore and can also have digits but _____ is not a variable.
(First 2 correct submissions accepted)
(D)(.)(D)(.)(D)(.)(D)
Where,
D = (0|1|2|3|4|5|6|7|8|9) +
(1|2|3|4|5|6|7|8|9)(0|1|2|3|4|5|6|7|8|9) +
(1)(0|1|2|3|4|5|6|7|8|9)(0|1|2|3|4|5|6|7|8|9) +
(2)(0|1|2|3|4)(0|1|2|3|4|5|6|7|8|9) +
(2)(5)(0|1|2|3|4|5)
3. Given |r| the length of the regular expression, and |x| is the length of the input string
write down the time and space complexity to test whether the string belongs to the
regular expression or not by an (a) NFA and (b) DFA. (First 7 correct submissions
accepted)
States={1,2,3}
start state={1}
final state={3}
transition function :
d(1,F)=2
d(2,*)=1
d(2,epsilon)=3
CFG for the second problem where each 'a' must be followed by a 'b' :
S -> Ab
A -> a | Ab | Aba
The CFG
S iEtSS’ | a
S’ eS | ε
Eb
S’ T e $,e
E F b T
a b i e t $
S Sa S iEtSS’
S’ S’ eS S’ ε
S’ ε
E Eb
$ ( ) Id ^ * / + -
$ < < < < < < < <
( > < = < < < < < <
) > > > > > > > >
Id > > > > > > > >
^ > < > < <
* > < > < < > >
/ > < > < < > >
+ > < > < < < < > >
- > < > < < < < > >
The precedence relations which have been left blank could not be determined by the
specified rules .