You are on page 1of 2

(1) Suppose that Σ = {d1, d2, d3, s1, s2, c1, c2, c3, c4, n1, n2}.

Design the regular expression r


such that L(r) is the language which contains the strings that buyers enter the machine.

Stage 1: insert coins (at least one coin). -> State A

Stage 2: pick a drink or a snack. -> State B

Stage 3: pick number of drinks or snacks. -> State C

Stage 4: Push button S to start. -> State D

Stage 5: Dispensed – Quit -> State E

(c1+c2+c3+c4)+(s1+s2+s3+d1+d2+d3)(n1+n2)S

So the complete regular expression is

L(r) = (s1+s2+s3+d1+d2+d3).(n1+n2). (c1+c2+c3+c4)(S)

Q = {A, B, C, D, E}

∑ = {s1, s2, s3, d1, d2, d3, n1, n2, c1, c2, c3, c4}

F={E}

(2) Design an NFA which accept the language L(r).

You might also like